Example #1
0
 public bool checkNearestBall(ArrayList b)
 {
     if(transform.position.y >= 530f/640f*Camera.main.orthographicSize) {
         Camera.main.GetComponent<mainscript>().controlArray = addFrom(b, Camera.main.GetComponent<mainscript>().controlArray);
         b.Clear();
         return true;    /// don't destroy
     }
     if(findInArray(Camera.main.GetComponent<mainscript>().controlArray, gameObject)){b.Clear(); return true;} /// don't destroy
     b.Add(gameObject);
     foreach(GameObject obj in nearBalls) {
      		if(obj.gameObject.layer == 9 && obj != gameObject){
         //	if(findInArray(Camera.main.GetComponent<mainscript>().controlArray, obj.gameObject)){b.Clear(); return true;} /// don't destroy
         //	else{
                 float distTemp = Vector3.Distance(transform.position, obj.transform.position);
                 if(distTemp <= 0.8f&& distTemp > 0 ){
                 if(!findInArray(b, obj.gameObject)){
                     Camera.main.GetComponent<mainscript>().arraycounter ++;
                         if(obj.GetComponent<bouncer>().checkNearestBall( b))
                             return true;
                     }
                 }
     //		}
         }
     }
     return false;
 }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        restaurantmenus.restaurant_menus r1 = new restaurantmenus.restaurant_menus();
        string emailid = Session["main_res"].ToString();

        ArrayList a = new ArrayList(r1.category_retrieve(emailid));
        ArrayList b = new ArrayList();
        b.Clear();
        b = (ArrayList)a;

        foreach (string c in b)
        {
            string[] row = c.Split('^');
            // Adds the category name dropdown
            ListItem f = new ListItem();
            f.Value = row[0];
            f.Text = row[0];
            category.Items.Add(f);
           // Adds the category type dropdown
            ListItem g = new ListItem();
            g.Value = row[1];
            g.Text = row[1];
            cattype.Items.Add(g);

        }
    }
Example #3
0
    }//Page_Load

    private void QueryData()
    {
        #region
        //抓取本頁初次登記的時間

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB);
        ArrayList ParameterList = new ArrayList();//20091113

        ParameterList.Clear();
        TextBoxCode.Text = TextBoxCode.Text + "%";
        TextBoxName.Text = TextBoxName.Text + "%";
        ParameterList.Add(TextBoxCode.Text);
        ParameterList.Add(TextBoxName.Text);
        ParameterList.Add(TextBoxRowCountLimit.Text.Trim());


        DataTable Dt = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.QryFileForSLP, ParameterList);
        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();
        GridView1.SelectedIndex = -1;

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString());
        #endregion
    }
Example #4
0
 public void ToggleComPort(string comPort)
 {
     try
     {
         if (_comPort.IsOpen)
         {
             Log.Information($"For:{comPort} _comPort.IsOpen at:{DateTime.UtcNow}");
             _comPort.Close();
             Log.Information($"For:{comPort} _comPort.Close() at:{DateTime.UtcNow}");
             _inputBuffer?.Clear();
         }
         else
         {
             Log.Information($"For:{comPort} Just Before Opened at:{DateTime.UtcNow}");
             _comPort.PortName = comPort;
             _comPort.BaudRate = 115200;
             _comPort.DataBits = 8;
             _comPort.Parity   = Parity.None;
             _comPort.StopBits = StopBits.One;
             _comPort.Open();
             Log.Information($"For:{comPort} Just After Opened at:{DateTime.UtcNow}");
         }
     }
     catch (Exception e)
     {
         Log.Error($"For:{comPort} ToggleComPort at:{DateTime.UtcNow} error was caught. Details: {e.Message}");
         throw new PortHandlerOpenPortFailedException();
     }
 }
Example #5
0
  public static int    curLine, curCol;     // position of curCh


  public static void BinaryTreeLexMethod(Utils.ModuleAction action, out String moduleName) {
  //-----------------------------------|----------------------------------------
    moduleName = MODULENAME;
    switch (action) {
      case Utils.ModuleAction.getModuleName:
        return;
      case Utils.ModuleAction.initModule:
        caseSensitive = true;
        lt            = new LexicalTable();
        tokenStrArr   = new char[256];
        kwHt          = CreateHashtable();
        nHt           = CreateHashtable();
        nl            = new ArrayList();
        break;
      case Utils.ModuleAction.resetModule:
        kwHt.Clear();
        nHt.Clear();
        nl.Clear();
        break;
      case Utils.ModuleAction.cleanupModule:
        lt            = null;
        tokenStrArr   = null;
        kwHt          = null;
        nHt           = null;
        nl            = null;
        break;
    } // switch
  } // BinaryTreeLexMethod
Example #6
0
        /// <summary>
        /// 批量采集参数
        /// </summary>
        private void Collecting()
        {
            while (b_windowShow)
            {
                if (!m_isThreadRun || m_opcUaClient == null || !m_opcUaClient.Connected)
                {
                    break;
                }

                try
                {
                    // 批量读取: 因为不能保证读取的节点类型一致,所以只提供统一的DataValue读取,每个节点需要单独解析
                    objs?.Clear();
                    int index = 0;
                    foreach (DataValue value in m_opcUaClient.ReadNodes(nodes))
                    {
                        // 获取到了值,具体的每个变量的解析参照上面类型不确定的解析
                        object data = value.WrappedValue.Value;

                        // 单独操作data
                        if (data != null)
                        {
                            objs.Add(data);
                        }
                        else
                        {
                            m_main.LogNetProgramer.WriteError("采集异常", "节点名:" + nodes[index] + ",读取失败!");
                            //m_isThreadRun = false;
                            //btnStart.UIText = "采集";
                            break;
                        }
                        index++;
                    }
                }
                catch (Exception ex)
                {
                    m_isThreadRun = false;
                    CommonLibrary.Log.LogHelper.WriteLog("OPC采集焊接参数异常", ex);
                }

                if (m_isThreadRun && objs.Count > 0)
                {
                    Invoke(new Action(() =>
                    {
                        txtXPos.Text      = Convert.ToDouble(objs[0]).ToString("0.000");
                        txtYPos.Text      = Convert.ToDouble(objs[1]).ToString("0.000");
                        txtZPos.Text      = Convert.ToDouble(objs[2]).ToString("0.000");
                        txtRPos.Text      = Convert.ToDouble(objs[3]).ToString("0.000");
                        txtWeldPower.Text = Convert.ToDouble(objs[4]).ToString("0.000");
                        txtPressure.Text  = Convert.ToDouble(objs[5]).ToString("0.000");
                        txtFlow.Text      = Convert.ToDouble(objs[6]).ToString("0.000");
                        txtWeldTime.Text  = Convert.ToDouble(objs[8]).ToString("0.000");
                        txtSpeed.Text     = objs[7].ToString();
                    }));

                    // if (!String.IsNullOrEmpty(m_barcode)) m_startSave = true;
                }
                Thread.Sleep(1000);
            }
        }
    public string GetItemName(string Barcode)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        OUT01_SKUDBO MSKU = new OUT01_SKUDBO(ConnectionDBStr);

        if (Barcode.Trim() != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Barcode.Trim());
            ParameterList.Add(Barcode.Trim());
            ParameterList.Add(""); // ItemName
            ParameterList.Add(""); // _MDC_START_DATE
            ParameterList.Add(""); // MDC_START_DATE
            ParameterList.Add(""); // MDC_END_DATE
            ParameterList.Add(""); // MDC_END_DATE
            ParameterList.Add(""); // RootNo
            ParameterList.Add(""); // RootNo
            ParameterList.Add(""); // VENDOR
            ParameterList.Add(""); // VENDOR
            ParameterList.Add("999");

            DataTable dt = MSKU.doQueryItemSLP(ParameterList);
            Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["ITEM_NAME"].ToString() : "查無資料");
        }
    
        return Name;        

    }
    public string BankName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainBankMain BCO = new MaintainBankMain(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Code); //Bank_ID

            DataTable Dt = BCO.QueryForSLP(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                Name = Dt.Rows[0]["BANK_NAME"].ToString().Trim();
            }
            else
            {
                Name = "查無資料";
            }
        }

        return Name;
    }
    public string GiftName(string Code,
                           string ITEM,
                           string PERIOD
                           )
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainGift bcoGift = new MaintainGift(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(Code);
            ParameterList.Add(ITEM);
            ParameterList.Add(PERIOD); 

            DataTable dt = bcoGift.QueryForSLP(ParameterList);
            
            Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["VIRTUAL_NAME"].ToString() : "查無資料");
        }

        return Name;
    }
    public string PARAMName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainDisParameter BCO = new MaintainDisParameter(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(9999);
            DataTable Dt = BCO.QuerySwitch(ALOCommon.QueryType.ALL, ParameterList);

            int res = 0;
            foreach (DataRow dr in Dt.Rows)
            {
                if (dr["Code"].ToString().Trim() == Code)
                {
                    Name = dr["Name"].ToString().Trim();
                    res++;
                }
            }

            if (res != 1)
            {
                Name = "查無資料";
            }
        }

        return Name;
    }
    public string BusDocumentMetaName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainBusDocumentMeta BCO = new MaintainBusDocumentMeta(ConnectionDBStr);

        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();        
        ParameterList.Add(Code);

        if (Code != "")
        {
            DataTable Dt = BCO.QueryForSLP(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                Name = Dt.Rows[0]["Name"].ToString().Trim();
            }
            else
            {
                Name = "無資料";
            }
        }

        return Name;
    }
    public void sendEmail(string recipID, string msgBody)
    {
        ArrayList msgList = new ArrayList();

        msgList.Clear();
        msgList.Add(recipID);

            foreach (string item in msgList)
            {
                try
                {
                    MailMessage message = new MailMessage();
                    message.To.Add(item);
                    message.Subject = "AutoInvoicing Notification";
                    message.From = new MailAddress("*****@*****.**");
                    message.Body = msgBody;
                    message.ReplyTo = new MailAddress("*****@*****.**");
                    message.IsBodyHtml = true;
                    System.Net.Mail.SmtpClient smtp = new SmtpClient("192.168.240.27");
                    smtp.Send(message);
                    message.Dispose();
                }
                catch (Exception e)
                {
            }
        }
    }
    public string GetDoName(string Code,
                            string Z_O
                            )
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainDoBase co_main = new MaintainDoBase(ConnectionDBStr);        

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Code);
            ParameterList.Add(Z_O);              
            
            DataTable Dt = co_main.QueryForSLP(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                Name = Dt.Rows[0]["CODE_NAME"].ToString().Trim();
            }
            else
            {
                Name = "查無資料";
            }
        }

        return Name;
    }
    public GameObject[] selected_terrains(byte ops)
    {
        terrains = new ArrayList();
        terrains.Clear ();

        if((ops & TERRAIN_1) == TERRAIN_1){
            terrains.Add(terrain[0]);
        }
        if((ops & TERRAIN_2) == TERRAIN_2){
            terrains.Add(terrain[1]);
        }
        if((ops & TERRAIN_3) == TERRAIN_3){
            terrains.Add(terrain[2]);
        }
        if((ops & TERRAIN_4) == TERRAIN_4){
            terrains.Add(terrain[3]);
        }
        if((ops & TERRAIN_5) == TERRAIN_5){
            terrains.Add(terrain[4]);
        }
        if((ops & TERRAIN_6) == TERRAIN_6){
            terrains.Add(terrain[5]);
        }
        if((ops & TERRAIN_7) == TERRAIN_7){
            terrains.Add(terrain[6]);
        }
        if((ops & TERRAIN_8) == TERRAIN_8){
            terrains.Add(terrain[7]);
        }
        return terrains.ToArray() as GameObject[];
    }
Example #15
0
        //
        // private methods
        //

        private void Clear()
        {
            _CRL = null;
            _subjectKeyIds?.Clear();
            _subjectNames?.Clear();
            _issuerSerials?.Clear();
            _certificates?.Clear();
        }
Example #16
0
 /// <devdoc>
 /// Clears all elements in the table.
 /// </devdoc>
 public void Clear()
 {
     if (_readOnly)
     {
         throw new NotSupportedException(SR.OrderedDictionary_ReadOnly);
     }
     _objectsTable?.Clear();
     _objectsArray?.Clear();
 }
Example #17
0
    void loadForecastData()
    {
        forecast_d = new ArrayList();
        System.IO.StreamReader file = new System.IO.StreamReader(forecastpath);

        string line = file.ReadLine();

        forecast_d.Clear();
        while (line != null)
        {
            forecast_d.Add(float.Parse(line));
            line = file.ReadLine();
        }
    }
Example #18
0
        /// <summary>
        /// Clears the state of this helper.
        /// </summary>
        public void Clear()
        {
            if (m_children != null)
            {
                foreach (ISupportsMementos child in m_children)
                {
                    child.MementoChangeEvent -= m_childChangeHandler;
                }
                m_children.Clear();
            }
            m_problemChildren?.Clear();


            m_hasChanged = true; // Forces the parent to regather a memento.
        }
Example #19
0
    private void UC_Copy()
    {
        try
        {
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            //來電紀錄
            ParameterList.Add(this.slp_up_CHAN_NO.Text.Trim());//通路
            ParameterList.Add(this.slp_up_Z_O.Text.Trim());//營業所
            ParameterList.Add(this.txt_up_CODE.Text.Trim());//流水編號
            ParameterList.Add(this.slp_up_STORE.Text.Trim());//門市
            ParameterList.Add(this.slp_up_BUSDATE.Text.Trim());//處理日期 
            ParameterList.Add(this.txt_up_ANSWER_TIME.Text.Trim());//接聽時間
            ParameterList.Add(this.slp_up_SAL_ID.Text.Trim());//營業人員
            ParameterList.Add(this.slp_up_BUSUID.Text.Trim());//處理人員
            ParameterList.Add(this.txt_up_ROUTE_ID.Text.Trim());//路線
            ParameterList.Add(this.txt_up_ROUTE_STEP.Text.Trim());//路順
            ParameterList.Add(this.txt_up_STORE_TEL_AREA.Text.Trim());//電話-區域號碼
            ParameterList.Add(this.txt_up_STORE_TEL_NO.Text.Trim());//電話號碼
            ParameterList.Add(this.txt_up_FAX_AREA.Text.Trim());//傳真-區域號碼
            ParameterList.Add(this.txt_up_FAX_NO.Text.Trim());//傳真號碼
            ParameterList.Add(this.txt_up_STORE_ADDRESS.Text.Trim());//地址

            //客服單
            ParameterList.Add(this.slp_down_PROC_UNIT.Text.Trim());//負責單位
            ParameterList.Add(this.slp_down_PROC_MAN.SelectedValue);//負責人
            //ParameterList.Add(this.txt_down_REQUEST_NO.Text.Trim());//原因代號
            ParameterList.Add(this.slp_down_REQUEST_NO.Text.Trim());//原因代號
            ParameterList.Add(this.slp_down_GRADE.Text.Trim());//等級
            ParameterList.Add(this.txt_down_REQUEST_STATEMENT.Text.Trim());//問題陳述
            ParameterList.Add(this.slp_down_CLOSE_DATE.Text.Trim());//處理日期
            ParameterList.Add(this.txt_down_CLOSE_TIME.Text.Trim());//處理時間
            ParameterList.Add(this.slp_down_ANSWER_USER.Text.Trim());//處理人員
            ParameterList.Add(this.slp_down_PROC_FLAG.Text.Trim());//處理狀態
            ParameterList.Add(this.txt_down_PROC_STATEMENT.Text.Trim());//處理敘述

            Copy_yet = true;

            Response.Redirect("CRM032.aspx?Code=CRM03&mode=INSERT", false);
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Example #20
0
    public string find(string word)
    {
        char look;
        ArrayList mae = new ArrayList(); ;
        ArrayList usiro = new ArrayList(); ;

        for (int i = 0; i < word.Length; i++)
        {
            usiro.Clear();
            mae.Clear();
            look = word[i];
            for (int j = i + 1; j < word.Length; j++)
            {
                if(look == word[j] && j == i + 1)
                {
                    return "Dislikes";
                }
                else if (look == word[j])
                {
                    for (int k = j + 1; k < word.Length; k++)
                    {
                        usiro.Add(word[k]);

                    }

                    for (int x = 0; x < mae.Count; x++)
                    {

                        for (int y = 0; y < usiro.Count; y++)
                        {
                            if ((char)mae[x] == (char)usiro[y])
                            {
                                return "Dislikes";
                            }

                        }
                    }
                }
                else
                {
                    mae.Add(word[j]);
                }
            }

        }

        return "Likes";
    }
Example #21
0
 public bool FindPath(PathElement peTo, out ArrayList alTrainPath)
 {
     alTrainPath = new ArrayList();
     int[] sources = this.GetSources();
     foreach (int num2 in sources)
     {
         int num;
         PathElement connectedPath = this.GetConnectedPath(num2, out num);
         alTrainPath.Clear();
         if ((connectedPath != null) && this.FindPath(peTo, this, connectedPath, num, alTrainPath))
         {
             return true;
         }
     }
     return false;
 }
Example #22
0
        public void TestClearBasic()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            string[] strHeroes = new string[]
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                null,
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                null,
                "Thor",
                "Wildcat",
                null
            };

            //[]  Clear list with elements

            // Construct ArrayList.
            ArrayList arrList = new ArrayList(strHeroes);
            arrList.Clear();

            Assert.Equal(0, arrList.Count);

            //[]  Clear list with no elements
            // Construct ArrayList.
            arrList = new ArrayList();
            arrList.Clear();
            Assert.Equal(0, arrList.Count);
        }
Example #23
0
        protected virtual void Dispose(bool disposing)
        {
            // Exit if we've already cleaned up this object.
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                //  ny General Cleanup goes here
                Initialize(false);
                _errors?.Clear();
            }

            // Remember that we've executed this code
            disposed = true;
        }
    }//Page_Load

    private void QueryData()
    {
        #region

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        DataTable Dt = new DataTable();
        ALOModel.MaintainDisCopy BCO = new ALOModel.MaintainDisCopy(ConnectionDB);

        ArrayList ParameterList = new ArrayList();

        ParameterList.Clear();
        ParameterList.Add(SLP_SLPDate1.Text.Trim());
        ParameterList.Add(SLP_User1.Text.Trim());
        ParameterList.Add(txt_OldDisNo.Text.Trim());
        ParameterList.Add(SLP_SKU1.Text.Trim());
        ParameterList.Add(SLP_ItemPeriod1.Text.Trim());

        Dt = BCO.QueryCopyErrorRecord(ParameterList);

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();
        GridView1.SelectedIndex = -1;

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString());


        if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
        {
            ResultMsgLabel.Text = "查無資料";
            btn_Export.Enabled = false;
            //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
        }
        else 
        {
            btn_Export.Enabled = true;
        }

        #endregion
    }//QueryData
    // int xx = Convert.ToInt32(Request.QueryString["RoleID"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    {
        this.ErrorMessage.Visible = false;
        this.ErrorMessage.Visible = false;
        if (!Page.IsPostBack)
        {

            string str = "select [RoleName] from RolePermission where ID = " + Request.QueryString["RoleID"].ToString();
            DataTable Rolename = dbObj.GetDataSet(dbObj.GetCommandStr(str), "RolePermission");
            this.RoleName.Text = Rolename.Rows[0][0] + "的权限";
            ArrayList myArrayList = new ArrayList();
            myArrayList.Add("查看文件");
            myArrayList.Add("删除文件");
            myArrayList.Add("上传文件");
            myArrayList.Add("下载文件");

            permCheck.DataSource = myArrayList;
            permCheck.DataBind();
            string str1 = "select[ReadFile],[DeleteFile],[Upload],[DownLoad] from  RolePermission where ID= " + Request.QueryString["RoleID"].ToString();
            DataTable f**k = dbObj.GetDataSet(dbObj.GetCommandStr(str1), "RolePermission");

            for (int i = 0; i < 4; i++)
            {
                if (Convert.ToBoolean(f**k.Rows[0][i].ToString().Trim()) == true)
                {
                    permCheck.Items[i].Selected = true;
                }
            }
            myArrayList.Clear();
            myArrayList.Add("个人信息");
            permCheck1.DataSource = myArrayList;
            permCheck1.DataBind();
            str1 = "select[ReadSelf] from  RolePermission where ID= " + Request.QueryString["RoleID"].ToString();
            DataTable f***s = dbObj.GetDataSet(dbObj.GetCommandStr(str1), "RolePermission");

            for (int i = 0; i < 1; i++)
            {
                if (Convert.ToBoolean(f***s.Rows[0][i].ToString().Trim()) == true)
                {
                    permCheck1.Items[i].Selected = true;
                }
            }
        }
    }
Example #26
0
        public void TestArrayListWrappers()
        {
            ArrayList alst1;
            string strValue;
            Array arr1;

            //[] Vanila test case - ToArray returns an array of this. We will not extensively test this method as
            // this is a thin wrapper on Array.Copy which is extensively tested elsewhere
            alst1 = new ArrayList();
            for (int i = 0; i < 10; i++)
            {
                strValue = "String_" + i;
                alst1.Add(strValue);
            }

            ArrayList[] arrayListTypes = {
                                            alst1,
                                            ArrayList.Adapter(alst1),
                                            ArrayList.FixedSize(alst1),
                                            alst1.GetRange(0, alst1.Count),
                                            ArrayList.ReadOnly(alst1),
                                            ArrayList.Synchronized(alst1)};

            foreach (ArrayList arrayListType in arrayListTypes)
            {
                alst1 = arrayListType;
                arr1 = alst1.ToArray(typeof(string));

                for (int i = 0; i < 10; i++)
                {
                    strValue = "String_" + i;
                    Assert.Equal(strValue, (string)arr1.GetValue(i));
                }

                //[] this should be covered in Array.Copy, but lets do it for
                Assert.Throws<InvalidCastException>(() => { arr1 = alst1.ToArray(typeof(int)); });
                Assert.Throws<ArgumentNullException>(() => { arr1 = alst1.ToArray(null); });
            }

            //[]lets try an empty list
            alst1.Clear();
            arr1 = alst1.ToArray(typeof(Object));
            Assert.Equal(0, arr1.Length);
        }
    public string GetPMAName(string Code,
                             string RootNo
                            )
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainItemClassify bco = new MaintainItemClassify(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Code);
            ParameterList.Add(RootNo);

            DataTable dt = bco.QueryPMAForSLP2(ParameterList);

            Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["PMA_NAME"].ToString() : "查無資料");
        }

        return Name;
    }
    public EquationGenerator(byte ops,int displayMode)
    {
        operations = new ArrayList();

        operations.Clear();
        this.displayMode = displayMode;
        solution = (int)Random.Range(0,9);
        equation = "";

        if((ops & ADDITION) == ADDITION){
            operations.Add("+");
        }
        if((ops & SUBTRACTION) == SUBTRACTION){
            operations.Add("-");
        }
        if((ops & MULTIPLICATION) == MULTIPLICATION){
            operations.Add("x");
        }
        if((ops & DIVISION) == DIVISION){
            operations.Add("/");
        }
    }
    private void QueryData()
    {
        #region
        try
        {
            string SessionIDName = string.Format("{0}_{1}", strPrefixed, PageTimeStamp.Value);
            ALOModel.MaintainStAccept BCO = new ALOModel.MaintainStAccept(ConnectionDB);

            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(SLP_SLPDate1.Text.Trim() == "" ? null : SLP_SLPDate1.Text.Trim());
            ParameterList.Add(txt_PickBatch.Text.Trim() == "" ? null : txt_PickBatch.Text.Trim());
            ParameterList.Add(Request.QueryString["UserIDKey"]);
            ParameterList.Add(string.Format("{0}_{1}", Request.QueryString["SessionIDKey"], Request.QueryString["UserIDKey"]));

            DataTable dt = BCO.QueryCheckErrorInfo(ParameterList);
            if (dt != null && dt.Rows.Count > 0)
            {
                gv_Result.DataSource = dt;
                gv_Result.PageSize = (TextBoxPagesize_Query.Text == "") ? 20 : (int.Parse(TextBoxPagesize_Query.Text) <= 0) ? 20 : int.Parse(TextBoxPagesize_Query.Text);
                gv_Result.DataBind();
                Session[SessionIDName] = dt;
                btn_Export.Enabled = true;
            }
            else
            {
                btn_Export.Enabled = false;
                gv_Result.DataBind();
                ResultMsgLabel.Text = "查無資料";
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
Example #30
0
        private void CleanButton_Click(object sender, EventArgs e)
        {
            LogBox.Text = string.Empty;

            if (ToBeDeleted == null || ToBeDeleted.Count == 0)
            {
                LogBox.AppendText("There is nothing to be deleted.");
            }
            else
            {
                var dialogResult =
                    MessageBox.Show(@"Are you sure you would like to deleted the selected files?", @"Confirmation",
                                    MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    DeleteFiles();
                }
            }

            ToBeDeleted?.Clear();
            CleanButton.Enabled = false;
        }
    private void QueryData()
    {
        #region
        try
        {
            string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

            ALOModel.MaintainDisRecord BCO = new ALOModel.MaintainDisRecord(ConnectionDB);

            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO);
            ParameterList.Add(s_ITEM);
            ParameterList.Add(s_PERIOD);

            DataTable dt = BCO.QueryDisStoreWithImportPOInfo(ParameterList);
            if (dt != null && dt.Rows.Count > 0)
            {
                this.btn_Save.Enabled = true;
                this.gv_Result.DataSource = dt;
                this.gv_Result.PageSize = 10;
                this.gv_Result.PageIndex = 0;
                this.gv_Result.DataBind();
                Session[SessionIDName] = dt;
            }
            else
            {
                ResultMsgLabel.Text = "查無資料";
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
        private void EnsurePropertyMap()
        {
            lock (this)
            {
                if (_properties == null)
                {
                    _properties = new Hashtable<string, IProperty[]>();
                    var props = GetType().GetAnnotation<IProperties>(typeof (IProperties));
                    if (props == null) 
                        return;
                    string currentSignature = null;
                    ArrayList<IProperty> list = new ArrayList<IProperty>();
                    var empty = new IProperty[0];

                    foreach (var property in props.Properties())
                    {
                        var signature = property.DeclaringTypeDescriptor();

                        if (currentSignature != signature)
                        {
                            if(currentSignature != null)
                                _properties.Put(currentSignature, list.ToArray(empty));

                            currentSignature = signature;
                            list.Clear();
                        }

                        list.Add(property);
                    }

                    if (currentSignature != null)
                        _properties.Put(currentSignature, list.ToArray(empty));

                }
            }
        }
Example #33
0
 /// <summary>
 /// Remove all frames from frame list
 /// </summary>
 public void Clear()
 {
     _Frames.Clear();
 }
Example #34
0
 public void Reset()
 {
     done = false;
     tasks.Clear();
 }
Example #35
0
    // Update is called once per frame
    void Update()
    {
        //foreach (DictionaryEntry u in lstRunning)
        //{
        //    GameObject vehicle = (GameObject)u.Key;
        //    double speed = (double)u.Value;


        //    vehicle.transform.Translate(0, 0, Convert.ToSingle(speed), vehicle.transform);
        //}

        for (int i = 0; i < 8; i++)
        {
            ChangedToIdle.Clear();
            foreach (DictionaryEntry u in Streets[i])
            {
                if (LightControl.state)
                {
                    if (i == 0 || i == 1 || i == 4 || i == 5)
                    {
                        continue;
                    }
                }
                else
                {
                    if (i == 2 || i == 3 || i == 6 || i == 7)
                    {
                        continue;
                    }
                }


                GameObject vehicle = (GameObject)u.Key;
                double     speed   = (double)u.Value;

                Vector3 position = vehicle.transform.position;
                position.x += Convert.ToSingle(speed * ((Vector3)((DictionaryEntry)StartPoints[i]).Value).x);
                position.y += Convert.ToSingle(speed * ((Vector3)((DictionaryEntry)StartPoints[i]).Value).y);
                position.z += Convert.ToSingle(speed * ((Vector3)((DictionaryEntry)StartPoints[i]).Value).z);
                vehicle.transform.position = position;
                Vector3 rotation = vehicle.transform.eulerAngles;
                switch (i)
                {
                case 0:
                case 1:
                    if (position.z > 600)
                    {
                        ChangedToIdle.Add(u);
                    }
                    break;

                case 2:
                case 3:
                    if (position.x < 0)
                    {
                        rotation.y -= 270;
                        ChangedToIdle.Add(u);
                    }
                    break;

                case 4:
                case 5:
                    if (position.z < 0)
                    {
                        rotation.y -= 180;
                        ChangedToIdle.Add(u);
                    }
                    break;

                case 6:
                case 7:
                    if (position.x > 500)
                    {
                        rotation.y -= 90;
                        ChangedToIdle.Add(u);
                    }
                    break;
                }
                vehicle.transform.eulerAngles = rotation;
            }

            foreach (DictionaryEntry u in ChangedToIdle)
            {
                GameObject vehicle = (GameObject)u.Key;
                Streets[i].Remove(u);
                lstIdle.Add(vehicle);
            }
        }
    }
Example #36
0
        private void savefile_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(filename.Text))
            {
                MessageBox.Show("数据库定义文件不能为空!");
                return;
            }

            if (String.IsNullOrEmpty(dbname.Text))
            {
                MessageBox.Show("数据库名称不能为空!");
                return;
            }

            if (String.IsNullOrEmpty(dbcode.Text))
            {
                MessageBox.Show("数据库代码不能为空!");
                return;
            }

            if (ddlProject.SelectedValue.ToString() == DropAddFlag.Select.ToString())
            {
                Global.ShowSysInfo("请选择所属项目!");
                return;
            }

            SqlConnection conn = null;
            SqlCommand    cmd  = null;

            try
            {
                PdmHelper pdm = new PdmHelper(filename.Text);
                pdm.InitData();
                conn = DBUtils.GetConnection();
                cmd  = DBUtils.GetCommand();

                cmd.Transaction = conn.BeginTransaction();

                #region Save DB

                ArrayList paras = new ArrayList();
                paras.Add(DBUtils.MakeInParam("DBCode", SqlDbType.NVarChar, 40, dbcode.Text));
                SqlDataReader reader = DBUtils.ExecuteReader(conn, cmd, CommandType.StoredProcedure, "dbo.P_Get_DBByCode", paras);

                PdmDatabase db = new PdmDatabase();

                if (reader.Read())
                {
                    db.OnPopulate(reader);
                }

                reader.Close();

                if (String.IsNullOrEmpty(db.DBCode))
                {
                    db.DBCode = dbcode.Text;
                    db.DBName = dbname.Text;
                }

                db.ProjectID = ddlProject.SelectedValue.ToString();

                if (db.DBID <= 0)
                {
                    // 新数据库文件
                    paras.Clear();
                    paras.Add(DBUtils.MakeOutParam("DBID", SqlDbType.Int));
                    paras.Add(DBUtils.MakeInParam("DBName", SqlDbType.NVarChar, 40, db.DBName));
                    paras.Add(DBUtils.MakeInParam("DBCode", SqlDbType.NVarChar, 40, db.DBCode));
                    paras.Add(DBUtils.MakeInParam("IsLog", SqlDbType.Bit, cbLog.Checked));
                    paras.Add(DBUtils.MakeInParam("DBType", SqlDbType.Int, DataBaseType.Oracle));
                    paras.Add(DBUtils.MakeInParam("ProjectID", SqlDbType.VarChar, db.ProjectID));
                    paras.Add(DBUtils.MakeInParam("ACTION", SqlDbType.Int, DataProviderAction.Create));

                    DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, "dbo.P_Save_DB", paras);

                    db.DBID = ((SqlParameter)paras[0]).Value != DBNull.Value ? Convert.ToInt32(((SqlParameter)paras[0]).Value) : 0;

                    db.DBSerial = 0;
                }
                else
                {
                    paras.Clear();
                    paras.Add(DBUtils.MakeInParam("DBID", SqlDbType.Int, db.DBID));
                    paras.Add(DBUtils.MakeInParam("DBName", SqlDbType.NVarChar, 40, db.DBName));
                    paras.Add(DBUtils.MakeInParam("DBCode", SqlDbType.NVarChar, 40, db.DBCode));
                    paras.Add(DBUtils.MakeInParam("ProjectID", SqlDbType.VarChar, db.ProjectID));
                    paras.Add(DBUtils.MakeInParam("IsLog", SqlDbType.Bit, cbLog.Checked));
                    paras.Add(DBUtils.MakeInParam("ACTION", SqlDbType.Int, DataProviderAction.Update));

                    DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, "dbo.P_Save_DB", paras);

                    if (cbLog.Checked)
                    {
                        db.DBSerial += 1;
                    }
                }

                # endregion Save DB


                # region Save Table & Columns

                PdmTable  oTable  = new PdmTable();
                PdmColumn oColumn = new PdmColumn();

                foreach (PdmTable pTable in pdm.Tables)
                {
                    pTable.DBID = db.DBID;
                    oTable.OnInit();

                    // 判断该表是否已经存在

                    paras.Clear();
                    paras.Add(DBUtils.MakeInParam("DBID", SqlDbType.Int, db.DBID));
                    paras.Add(DBUtils.MakeInParam("TableCode", SqlDbType.NVarChar, 40, pTable.TableCode.ToLower()));

                    reader = DBUtils.ExecuteReader(conn, cmd, CommandType.StoredProcedure, "dbo.P_Get_TableByCode", paras);

                    if (reader.Read())
                    {
                        oTable.OnPopulate(reader);
                    }

                    reader.Close();

                    if ((pTable.TableCode.ToLower().IndexOf("_pmt_") >= 0) || (pTable.TableCode.ToLower().IndexOf("pm_") >= 0))
                    {
                        pTable.IsPmt = true;
                    }

                    // 保存表信息

                    paras.Clear();
                    paras.Add(DBUtils.MakeInParam("DBID", SqlDbType.Int, db.DBID));
                    paras.Add(DBUtils.MakeInParam("TableCode", SqlDbType.NVarChar, 40, pTable.TableCode));
                    paras.Add(DBUtils.MakeInParam("TableName", SqlDbType.NVarChar, 40, pTable.TableName));
                    paras.Add(DBUtils.MakeInParam("Comment", SqlDbType.NVarChar, 400, pTable.Comment));
                    paras.Add(DBUtils.MakeInParam("IsPmt", SqlDbType.Bit, pTable.IsPmt));
                    paras.Add(DBUtils.MakeInParam("IsLog", SqlDbType.Bit, cbLog.Checked));

                    if (String.IsNullOrEmpty(oTable.TableCode))
                    {
                        paras.Add(DBUtils.MakeInParam("ACTION", SqlDbType.Int, DataProviderAction.Create));
                    }
                    else
                    {
                        paras.Add(DBUtils.MakeInParam("ACTION", SqlDbType.Int, DataProviderAction.Update));
                    }

                    DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, "dbo.P_Save_Table", paras);

                    SqlBaseProvider.DeleteColumn(conn, cmd, pTable, cbLog.Checked);

                    foreach (PdmColumn pColumn in pTable.Columns)
                    {
                        pColumn.DBID      = pTable.DBID;
                        pColumn.TableCode = pTable.TableCode;

                        SqlBaseProvider.SaveColumn(conn, cmd, pColumn);
                    }

                    if (String.IsNullOrEmpty(oTable.TableCode) || cbLog.Checked)
                    {
                        SqlBaseProvider.LogColumn(conn, cmd, pTable, true);
                    }

                    SqlBaseProvider.DeleteKey(conn, cmd, pTable, cbLog.Checked);

                    foreach (PdmKey pKey in pTable.Keys)
                    {
                        pKey.DBID      = pTable.DBID;
                        pKey.TableCode = pTable.TableCode;

                        SqlBaseProvider.SaveKey(conn, cmd, pKey);

                        foreach (PdmColumn pColumn in pKey.Columns)
                        {
                            SqlBaseProvider.SaveKeyColumn(conn, cmd, pKey, pColumn);
                        }
                    }

                    if (String.IsNullOrEmpty(oTable.TableCode) || cbLog.Checked)
                    {
                        SqlBaseProvider.LogKey(conn, cmd, pTable, true);
                    }

                    SqlBaseProvider.DeleteIndex(conn, cmd, pTable);

                    foreach (PdmIndex pIndex in pTable.Indexs)
                    {
                        pIndex.DBID      = pTable.DBID;
                        pIndex.TableCode = pTable.TableCode;

                        SqlBaseProvider.SaveIndex(conn, cmd, pIndex);

                        foreach (PdmColumn pColumn in pIndex.Columns)
                        {
                            SqlBaseProvider.SaveIndexColumn(conn, cmd, pIndex, pColumn);
                        }
                    }

                    if (String.IsNullOrEmpty(oTable.TableCode) || cbLog.Checked)
                    {
                        SqlBaseProvider.LogIndex(conn, cmd, pTable, true);
                    }
                }

                # endregion Save Table & Columns & Key  Index
Example #37
0
 /// <summary>
 /// Clears all the Elements of this Cell.
 /// </summary>
 public void Clear()
 {
     arrayList.Clear();
 }
Example #38
0
 /// <summary>
 /// Clear all
 /// </summary>
 public void Clear()
 {
     _Items.Clear();
 }
Example #39
0
        public void SendReceiveLocalSocketsLoop()
        {
            ArrayList toRemove       = new ArrayList(128);
            int       iSentData      = 0;
            int       iRecvData      = 0;
            int       iDataToSend    = 0;
            bool      bSomethingDone = false;

            byte [] recvData = new byte[1024 * 4];
            try
            {
                for (;;)
                {
                    bSomethingDone = false;
                    lock (m_Connections)
                    {
                        foreach (s2hConnection conn in m_Connections.Values)
                        {
                            lock (conn)
                            {
                                // a connection not yet set ready by the client should be ignored
                                if (!conn.bReady)
                                {
                                    continue;
                                }
                                if (!conn.Connected && !conn.NullPacketSent)
                                {
                                    // connection lost: push a null packet on the queue
                                    // to notify the WS Client
                                    conn.DataRecievedQueue.Enqueue(new s2hConnectionData(null, 0));
                                    conn.NullPacketSent = true;
                                    continue;
                                }

                                /////////////////////////////////////////////
                                // send the pending data to the local socket
                                /////////////////////////////////////////////
                                if (conn.CanSend && conn.DataToSendQueue.Count > 0)
                                {
                                    bSomethingDone = true;
                                    // peek first packet
                                    s2hConnectionData buf =
                                        (s2hConnectionData)conn.DataToSendQueue.Peek();
                                    if (buf.data == null)
                                    {
                                        // null packet: this means that the connection
                                        // has been closed on the WS Client side
                                        conn.Close();
                                        toRemove.Add(conn.handle);
                                    }
                                    else
                                    {
                                        iDataToSend = buf.data.Length - buf.index;
                                        iSentData   = conn.SendSimple(buf.data, buf.index, iDataToSend);
                                        if (iSentData < iDataToSend)
                                        {
                                            buf.index += iSentData;                                             // partial data was sent
                                        }
                                        else
                                        {
                                            conn.DataToSendQueue.Dequeue();                                             // full data was sent
                                        }
                                    }
                                }

                                /////////////////////////////////////////////
                                // buffer the data received from local socket
                                // NOTE: max of m_iMaxRecvDataQueueLen packets
                                // are enqueued
                                /////////////////////////////////////////////
                                if (conn.CanRecv && conn.DataRecievedQueue.Count < m_iMaxRecvDataQueueLen)
                                {
                                    bSomethingDone = true;
                                    iRecvData      = conn.RecvSimple(recvData, 0, recvData.Length);
                                    if (iRecvData == 0)
                                    {
                                        // connection was closed by remote peer
                                        // push a null packet on the queue
                                        // to notify the WS Client
                                        conn.Close();
                                        conn.DataRecievedQueue.Enqueue(new s2hConnectionData(null, 0));
                                    }
                                    else
                                    {
                                        byte[] data = new byte[iRecvData];
                                        Array.Copy(recvData, 0, data, 0, iRecvData);
                                        s2hConnectionData buf = new s2hConnectionData(data, 0);
                                        conn.DataRecievedQueue.Enqueue(buf);
                                    }
                                }
                            }
                        }
                        // purge the closed connections
                        foreach (string s in toRemove)
                        {
                            m_Connections.Remove(s);
                        }
                        toRemove.Clear();
                    }

                    // sleep in case of inactivity; avoid 100% CPU
                    // and allow context switch to other WebServices Recv/Send threads
                    if (!bSomethingDone)
                    {
                        Thread.Sleep(20);
                    }
                }
            }
            catch (ThreadInterruptedException)
            {
                return;
            }
            catch (ThreadAbortException)
            {
                Thread.ResetAbort();
                return;
            }
        }
Example #40
0
        public static void Dump()
        {
            // Clear Resources
            Addons.Clear();
            Skills.Clear();
            Squads.Clear();
            Buildings.Clear();
            Units.Clear();
            Researches.Clear();
            MainForm.Log("Lua processing started...");
            DateTime start = DateTime.Now;


            Hashtable temp = (Hashtable)FilesTable.Clone();

            foreach (string lua in temp.Keys)
            {
                LuaInfo lInfo = temp[lua] as LuaInfo;
                if (lInfo.Type == InfoTypes.Building)
                {
                    StreamReader file = new StreamReader(File.OpenRead(lInfo.Path), System.Text.Encoding.ASCII);
                    file.BaseStream.Seek(0, SeekOrigin.Begin);

                    string s = file.ReadToEnd();

                    file.Close();

                    MatchCollection mccR = Regex.Matches(s, @"GameData\[""research_ext""\]\[""research_table""\]\[""research_([0-9]?[0-9]?)""\]\s=\s""(.*\\\\)?((?<research>.*)\.lua|(?<research>.*))""");
                    if (mccR.Count > 0)
                    {
                        foreach (Match mt in mccR)
                        {
                            Group research = mt.Groups["research"];

                            if (research.Success && research.Value != "")
                            {
                                string res = research.Value;
                                if (!res.EndsWith(".lua"))
                                {
                                    res += ".lua";
                                }
                                res = Path.Combine("research", res);
                                string path = DataPath.GetPath(res);

                                string  race   = GetRace(lInfo.Path);
                                LuaInfo resLua = new LuaInfo(path, InfoTypes.Research, race);

                                if (!FilesTable.Contains(res))
                                {
                                    FilesTable.Add(res, resLua);
                                }
                            }
                        }
                    }
                }
            }
            int count = FilesTable.Count;

            MainForm.BarSetMax(Bars.Data, count);
            // Collecting resources from lua files.
            foreach (string lua in FilesTable.Keys)
            {
                LuaInfo lInfo = FilesTable[lua] as LuaInfo;

                switch (lInfo.Type)
                {
                case InfoTypes.Research:
                    ResearchInfo rInfo = new ResearchInfo();
                    rInfo.Race     = lInfo.Race;
                    rInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil|(.*)\\", "");

                    try
                    {
                        LuaParser.ParseResearch(lInfo.Path, rInfo);
                    }
                    catch (Exception e)
                    {
                    }

                    MainForm.BarInc(Bars.Data);
                    Researches.Add(rInfo);
                    break;

                case InfoTypes.Unit:

                    SquadInfo sInfo = new SquadInfo();
                    sInfo.Race     = lInfo.Race;
                    sInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil", "");
                    LuaParser.ParseSquad(lInfo.Path, sInfo);
                    MainForm.BarInc(Bars.Data);
                    if (sInfo.Unit != null)
                    {
                        Squads.Add(sInfo);
                    }
                    break;

                case InfoTypes.Building:
                    BuildingInfo bInfo = new BuildingInfo();
                    bInfo.Race     = lInfo.Race;
                    bInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil", "");
                    LuaParser.ParseBuilding(lInfo.Path, bInfo);
                    MainForm.BarInc(Bars.Data);
                    Buildings.Add(bInfo);
                    break;
                }
            }
            Researches.Sort();
            Squads.Sort();
            Buildings.Sort();

            TimeSpan elapsed = DateTime.Now - start;

            MainForm.Log("Lua processing done in " + Math.Round(elapsed.TotalSeconds, 2) + " seconds.");
        }
        private void DataConsumerLoop()
        {
            while (true)
            {
                try
                {
                    _cancelSource.Token.ThrowIfCancellationRequested();
                    Task.Delay(50).Wait(_cancelSource.Token);
                }
                catch (OperationCanceledException)
                {
                    IncomingData?.Clear();
                    throw;
                }

                lock (IncomingQueue)
                {
                    if (IncomingQueue.Count <= 0)
                    {
                        continue;
                    }
                    while (IncomingQueue.TryDequeue(out var frame))
                    {
                        IncomingData.AddRange(frame);
                    }
                }

                do
                {
                    try
                    {
                        var raw = IncomingData.OfType <byte>().ToArray();

                        foreach (var hook in ScriptManager.Instance.RawStreamHooks)
                        {
                            hook?.OnRawDataAvailable(ref raw);
                        }

                        var msg = SPPMessage.DecodeMessage(raw);

                        Log.Verbose($">> Incoming: {msg}");

                        foreach (var hook in ScriptManager.Instance.MessageHooks)
                        {
                            hook?.OnMessageAvailable(ref msg);
                        }

                        MessageReceived?.Invoke(this, msg);

                        if (msg.TotalPacketSize >= IncomingData.Count)
                        {
                            IncomingData.Clear();
                            break;
                        }

                        IncomingData.RemoveRange(0, msg.TotalPacketSize);

                        if (ByteArrayUtils.IsBufferZeroedOut(IncomingData))
                        {
                            /* No more data remaining */
                            break;
                        }
                    }
                    catch (InvalidPacketException e)
                    {
                        InvalidDataReceived?.Invoke(this, e);
                        break;
                    }
                } while (IncomingData.Count > 0);
            }
        }
Example #42
0
 // Reset directoryBrowser and parameters related to directoryBrowser
 private void ClearFolders()
 {
     _folderLvl = 0;
     _folderHistory.Clear();
     _folders.Clear();
 }
        private void DataConsumerLoop()
        {
            while (true)
            {
                try
                {
                    _cancelSource.Token.ThrowIfCancellationRequested();
                    Task.Delay(50).Wait(_cancelSource.Token);
                }
                catch (OperationCanceledException)
                {
                    IncomingData?.Clear();
                    throw;
                }

                lock (IncomingQueue)
                {
                    if (IncomingQueue.Count <= 0)
                    {
                        continue;
                    }
                    while (IncomingQueue.TryDequeue(out var frame))
                    {
                        IncomingData.AddRange(frame);
                    }
                }

                var failCount = 0;
                do
                {
                    var        msgSize = 0;
                    SPPMessage?msg     = null;
                    try
                    {
                        var raw = IncomingData.OfType <byte>().ToArray();

                        foreach (var hook in ScriptManager.Instance.RawStreamHooks)
                        {
                            hook?.OnRawDataAvailable(ref raw);
                        }

                        msg     = SPPMessage.DecodeMessage(raw);
                        msgSize = msg.TotalPacketSize;

                        Log.Verbose($">> Incoming: {msg}");

                        foreach (var hook in ScriptManager.Instance.MessageHooks)
                        {
                            hook?.OnMessageAvailable(ref msg);
                        }

                        MessageReceived?.Invoke(this, msg);
                    }
                    catch (InvalidPacketException e)
                    {
                        // Attempt to remove broken message, otherwise skip data block
                        var somIndex = 0;
                        for (var i = 1; i < IncomingData.Count; i++)
                        {
                            if ((ActiveModel == Models.Buds &&
                                 (byte)(IncomingData[i] ?? 0) == (byte)SPPMessage.Constants.SOM) ||
                                (ActiveModel != Models.Buds &&
                                 (byte)(IncomingData[i] ?? 0) == (byte)SPPMessage.Constants.SOMPlus))
                            {
                                somIndex = i;
                                break;
                            }
                        }

                        msgSize = somIndex;

                        if (failCount > 5)
                        {
                            // Abandon data block
                            InvalidDataReceived?.Invoke(this, e);
                            break;
                        }

                        failCount++;
                    }

                    if (msgSize >= IncomingData.Count)
                    {
                        IncomingData.Clear();
                        break;
                    }

                    IncomingData.RemoveRange(0, msgSize);

                    if (ByteArrayUtils.IsBufferZeroedOut(IncomingData))
                    {
                        /* No more data remaining */
                        break;
                    }
                } while (IncomingData.Count > 0);
            }
        }
Example #44
0
        private void button4_Click(object sender, EventArgs e)
        {
            InstallingOption opt      = new InstallingOption(default(string[]), "", "");
            string           temppath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ZipperTemp";

            if (Directory.Exists(temppath))
            {
                for (int i = 0; i < int.MaxValue; i++)
                {
                    if (Directory.Exists(temppath + string.Format(" ({0})", i)))
                    {
                        continue;
                    }
                    temppath += string.Format(" ({0})", i);
                    break;
                }
            }
            Directory.CreateDirectory(temppath);
            foreach (string item in checkedListBox1.Items)
            {
                if (File.Exists(item))
                {
                    try
                    {
                        File.Copy(item, temppath + "\\" + Path.GetFileName(item));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Invalid file " + item + "\n" + ex.Message, ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (Directory.Exists(item))
                {
                    try
                    {
                        DirectoryCopy(item, temppath + "\\" + Path.GetFileName(item), true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Invalid Directory " + item + "\n" + ex.Message, ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            //try
            //{
            File.Copy(textBox1.Text, temppath + "\\" + Path.GetFileName(textBox1.Text));
            opt.EXEFile = Path.GetFileName(textBox1.Text);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Invalid exe file  " + textBox1.Text + "\n" + ex.Message, ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            InstOption formIO = new InstOption();

            paths.Clear();
            //foreach (object obj in checkedListBox1.CheckedItems)
            //{
            //    if (System.IO.File.Exists(obj.ToString()))
            //    {
            //        if (System.IO.Path.GetExtension(obj.ToString()).Equals(".ico")) { formIO.comboBox1.Items.Add(System.IO.Path.GetFileName(obj.ToString())); }
            //    }
            //    if (System.IO.Directory.Exists(obj.ToString()))
            //    {
            //        FileSearchFunction(obj.ToString());
            //        foreach (string s in paths.toArray())
            //        {
            //            if (System.IO.Path.GetExtension(s).Equals(".ico")) { formIO.comboBox1.Items.Add(System.IO.Path.GetFileName(obj.ToString()) + s.Replace(obj.ToString(), "")); }
            //        }
            //    }
            //}
            FileSearchFunction(temppath);
            foreach (string s in paths.toArray())
            {
                if (Path.GetExtension(s).Equals(".ico"))
                {
                    formIO.comboBox1.Items.Add(s.Replace(temppath + "\\", ""));
                }
            }
            formIO.Owner = this;
            formIO.ShowDialog();
            opt.ExtDefaultIcon = formIO.comboBox1.SelectedItem as string;
            Console.WriteLine(formIO.comboBox1.SelectedItem);
            opt.Extensions = formIO.textBox1.Lines;
            try
            {
                StreamWriter sw = File.CreateText(temppath + "\\" + "Installing.info");
                sw.WriteLine(opt.EXEFile);
                sw.WriteLine(opt.ExtDefaultIcon);
                foreach (string s in opt.Extensions)
                {
                    sw.WriteLine(s);
                }
                sw.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Zip-archive file | *.zip";
            DialogResult dr = sfd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                if (File.Exists(sfd.FileName))
                {
                    File.Delete(sfd.FileName);
                }
                ZipFile.CreateFromDirectory(temppath, sfd.FileName);
            }
            paths.Clear();
            //FileSearchFunction(temppath);
            //foreach (string s in paths.toArray())
            //{
            //    File.Delete(s);
            //}
            Directory.Delete(temppath, true);
        }
        private void getInfo([Optional] string numAfiliacion)
        {
            string strCadena, strMonedas;
            int    x       = 5;
            int    y       = 16;
            int    xMoneda = 45;
            int    yMoneda = 16;
            int    xRate   = 85;
            int    yRate   = 16;
            int    xDesc   = 140;
            int    yDesc   = 16;

            strCadena = "";
            strCadena = ejecutaOpera.ConsultaXMLConversorDCC(TypeUsuario.URL, numAfiliacion);
            strCadena = strCadena.Replace("&aacute;", "á");
            strCadena = strCadena.Replace("&eacute;", "é");
            strCadena = strCadena.Replace("&iacute;", "í");
            strCadena = strCadena.Replace("&oacute;", "ó");
            strCadena = strCadena.Replace("&uacute;", "ú");
            strCadena = strCadena.Replace("&ntilde;", "ñ");
            strCadena = strCadena.Replace("&uuml;", "ü");

            strCadena = strCadena.Replace("&Aacute;", "á");
            strCadena = strCadena.Replace("&Eacute;", "é");
            strCadena = strCadena.Replace("&Iacute;", "í");
            strCadena = strCadena.Replace("&Oacute;", "ó");
            strCadena = strCadena.Replace("&Uacute;", "ú");
            strCadena = strCadena.Replace("&Ntilde;", "ñ");
            strCadena = strCadena.Replace("&Uuml;", "ü");

            strMonedas = utilidadesMIT.GetDataXML("conversor", strCadena);

            cmboxTipoMoneda.Items.Clear();
            cmboxTipoMoneda.Items.Add("-- Seleccione Moneda --");

            if (lstActualMoneda.Count > 0)
            {
                lstActualMoneda.Clear();
            }

            lstActualMoneda.Add("-- Seleccione Moneda --");
            this.limpiaCampos();

            xmlDocto.LoadXml(strCadena);
            xmlMonedas = xmlDocto.GetElementsByTagName("moneda");

            if (xmlMonedas.Count > 0)
            {
                txtMontoConvertir.Enabled = true;
                cmdMonedas.Enabled        = true;

                for (int i = 0; i < xmlMonedas.Count; i++)
                {
                    cmboxTipoMoneda.Items.Add(xmlMonedas[i].ChildNodes[0].InnerText);
                    lstActualMoneda.Add(xmlMonedas[i].ChildNodes[1].InnerText);

                    //Para crear el path de las imagenes.
                    sPathUserBanderas = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\MIT\\Data\\Banderas\\";

                    if (!System.IO.Directory.Exists(sPathUserBanderas))
                    {
                        System.IO.Directory.CreateDirectory(sPathUserBanderas);
                    }

                    if (!System.IO.File.Exists(sPathUserBanderas + xmlMonedas[i].ChildNodes[2].InnerText + ".jpg"))
                    {
                        utilidadesMIT.DownloadFile(TRINP.url + "/pgs/jsp/cpagos/cargas/Picture/Banderas/" + xmlMonedas[i].ChildNodes[2].InnerText + ".jpg", sPathUserBanderas + xmlMonedas[i].ChildNodes[2].InnerText + ".jpg");
                    }

                    //se crean los objetos
                    if (System.IO.File.Exists(sPathUserBanderas + xmlMonedas[i].ChildNodes[2].InnerText + ".jpg"))
                    {
                        PictureBox pb = new PictureBox();
                        pb.Image    = Image.FromFile(sPathUserBanderas + xmlMonedas[i].ChildNodes[2].InnerText + ".jpg");
                        pb.SizeMode = PictureBoxSizeMode.StretchImage;
                        pb.Location = new Point(x, y);
                        pb.Size     = new System.Drawing.Size(28, 19);
                        y          += 30;
                        panelMonedas.Controls.Add(pb);
                    }

                    //Moneda
                    Label lblMoneda = new Label();

                    if (xmlMonedas[i].ChildNodes[0].InnerText.Contains('-'))
                    {
                        lblMoneda.Text = xmlMonedas[i].ChildNodes[0].InnerText.Split('-')[0];
                    }
                    else
                    {
                        lblMoneda.Text = xmlMonedas[i].ChildNodes[0].InnerText;
                    }

                    lblMoneda.Visible   = true;
                    lblMoneda.Size      = new System.Drawing.Size(35, 19);
                    lblMoneda.ForeColor = Color.Blue;
                    lblMoneda.Location  = new Point(xMoneda, yMoneda);
                    yMoneda            += 30;
                    panelMonedas.Controls.Add(lblMoneda);

                    //rate
                    Label lblRate = new Label();
                    lblRate.Text     = xmlMonedas[i].ChildNodes[1].InnerText;
                    lblRate.Visible  = true;
                    lblRate.Size     = new System.Drawing.Size(60, 19);
                    lblRate.Location = new Point(xRate, yRate);
                    yRate           += 30;
                    panelMonedas.Controls.Add(lblRate);

                    //descripcion
                    Label lblDesc = new Label();

                    if (xmlMonedas[i].ChildNodes[0].InnerText.Contains('-'))
                    {
                        lblDesc.Text = xmlMonedas[i].ChildNodes[0].InnerText.Split('-')[1];
                    }
                    else
                    {
                        lblDesc.Text = xmlMonedas[i].ChildNodes[0].InnerText;
                    }

                    lblDesc.Size     = new System.Drawing.Size(200, 19);
                    lblDesc.Visible  = true;
                    lblDesc.Location = new Point(xDesc, yDesc);
                    yDesc           += 30;
                    panelMonedas.Controls.Add(lblDesc);
                }
            }
            else
            {
                txtMontoConvertir.Enabled = false;
                cmdMonedas.Enabled        = false;
            }

            cmboxTipoMoneda.SelectedIndex = 0;
        }
Example #46
0
	/// <summary>
	/// 检查一次临时文件
	/// </summary>
	private void CheckFiles(object state)
	{
		lock (_fileList.SyncRoot)
		{
			if (_fileList.Count > 0)
			{
				ArrayList toBeRemoved = new ArrayList();//需要删除的临时文件列表

				int count = _fileList.Count;
				TempFile file = null;
				for (int i = 0; i < count; i++)
				{
					file = _fileList[i] as TempFile;

					//将临时文件的生存时间减少一次
					file.TimeEsacpe(CheckInterval);

					//如果临时文件到了生命终点
					if (file.TimeToLive <= 0)
					{
						toBeRemoved.Add(file);

						//从磁盘中删除这个临时文件
						FileInfo info = new FileInfo(file.Path);
						if (info.Exists)
						{
							info.Delete();
						}
					}
				}

				//从临时文件列表中删除这个临时文件
				foreach (TempFile tempfile in toBeRemoved)
				{
					_fileList.Remove(tempfile);
				}
				toBeRemoved.Clear();
			}
		}
	}
Example #47
0
        private static ArrayList prove(Hashtable cases, SelectableSource world, Statement[] goal, int maxNumberOfSteps)
        {
            // This is the main routine from euler.js.

            // cases: Resource (predicate) => IList of Sequent

            if (world != null)             // cache our queries to the world, if a world is provided
            {
                world = new SemWeb.Stores.CachedSource(world);
            }

            StatementMap cached_subproofs = new StatementMap();

            // Create the queue and add the first item.
            ArrayList queue = new ArrayList();
            {
                QueueItem start = new QueueItem();
                start.env    = new Hashtable();
                start.rule   = new Sequent(Statement.All, goal, null);
                start.src    = null;
                start.ind    = 0;
                start.parent = null;
                start.ground = new ArrayList();
                queue.Add(start);
                if (Debug)
                {
                    Console.Error.WriteLine("Euler: Queue: " + start);
                }
            }

            // The evidence array holds the results of this proof.
            ArrayList evidence = new ArrayList();

            // Track how many steps we take to not go over the limit.
            int step = 0;

            // Process the queue until it's empty or we reach our step limit.
            while (queue.Count > 0)
            {
                // deal with the QueueItem at the top of the queue
                QueueItem c = (QueueItem)queue[queue.Count - 1];
                queue.RemoveAt(queue.Count - 1);
                ArrayList g = new ArrayList(c.ground);

                // have we done too much?
                step++;
                if (maxNumberOfSteps != -1 && step >= maxNumberOfSteps)
                {
                    if (Debug)
                    {
                        Console.Error.WriteLine("Euler: Maximum number of steps exceeded.  Giving up.");
                    }
                    return(null);
                }

                // if each statement in the body of the sequent has been proved
                if (c.ind == c.rule.body.Length)
                {
                    // if this is the top-level sequent being proved; we've found a complete evidence for the goal
                    if (c.parent == null)
                    {
                        EvidenceItem ev = new EvidenceItem();
                        ev.head = new Statement[c.rule.body.Length];
                        bool canRepresentHead = true;
                        for (int i = 0; i < c.rule.body.Length; i++)
                        {
                            ev.head[i] = evaluate(c.rule.body[i], c.env);
                            if (ev.head[i].AnyNull)                             // can't represent it: literal in subject position, for instance
                            {
                                canRepresentHead = false;
                            }
                        }

                        ev.body = c.ground;
                        ev.env  = c.env;

                        if (Debug)
                        {
                            Console.Error.WriteLine("Euler: Found Evidence: " + ev);
                        }

                        if (!canRepresentHead)
                        {
                            continue;
                        }

                        evidence.Add(ev);

                        // this is a subproof of something; whatever it is a subgroup for can
                        // be incremented
                    }
                    else
                    {
                        // if the rule had no body, it was just an axiom and we represent that with Ground
                        if (c.rule.body.Length != 0)
                        {
                            g.Add(new Ground(c.rule, c.env));
                        }

                        // advance the parent being proved and put the advanced
                        // parent into the queue; unify the parent variable assignments
                        // with this one's
                        QueueItem r = new QueueItem();
                        r.rule   = c.parent.rule;
                        r.src    = c.parent.src;
                        r.ind    = c.parent.ind;
                        r.parent = c.parent.parent;
                        r.env    = (Hashtable)c.parent.env.Clone();
                        r.ground = g;
                        unify(c.rule.head, c.env, r.rule.body[r.ind], r.env, true);
                        r.ind++;
                        queue.Add(r);
                        if (Debug)
                        {
                            Console.Error.WriteLine("Euler: Queue Advancement: " + r);
                        }

                        // The number of live children for this parent is decremented since we are
                        // done with this subproof, but we store the result for later.
                        if (c.parent.solutions == null)
                        {
                            c.parent.solutions = new StatementList();
                        }
                        c.parent.solutions.Add(evaluate(r.rule.body[r.ind - 1], r.env));
                        decrementLife(c.parent, cached_subproofs);
                    }

                    // this sequent still has parts of the body left to be proved; try to
                    // find evidence for the next statement in the body, and if we find
                    // evidence, queue up that evidence
                }
                else
                {
                    // this is the next part of the body that we need to try to prove
                    Statement t = c.rule.body[c.ind];

                    // Try to process this predicate with a user-provided custom
                    // function that resolves things like mathematical relations.
                    // euler.js provides similar functionality, but the system
                    // of user predicates is completely different here.
                    RdfRelation b = FindUserPredicate(t.Predicate);
                    if (b != null)
                    {
                        Resource[] args;
                        Variable[] unifyResult;
                        Resource   value = evaluate(t.Object, c.env);

                        if (!c.rule.callArgs.ContainsKey(t.Subject))
                        {
                            // The array of arguments to this relation is just the subject of the triple itself
                            args        = new Resource[] { evaluate(t.Subject, c.env) };
                            unifyResult = new Variable[1];
                            if (t.Subject is Variable)
                            {
                                unifyResult[0] = (Variable)t.Subject;
                            }
                        }
                        else
                        {
                            // The array of arguments to this relation comes from a pre-grouped arg list.
                            args        = (Resource[])((ICloneable)c.rule.callArgs[t.Subject]).Clone();
                            unifyResult = new Variable[args.Length];

                            for (int i = 0; i < args.Length; i++)
                            {
                                if (args[i] is Variable)
                                {
                                    unifyResult[i] = (Variable)args[i];
                                    args[i]        = evaluate(args[i], c.env);
                                }
                            }
                        }

                        // Run the user relation on the array of arguments (subject) and on the object.
                        if (b.Evaluate(args, ref value))
                        {
                            // If it succeeds, we press on.

                            // The user predicate may update the 'value' variable and the argument
                            // list array, and so we want to unify any variables in the subject
                            // or object of this user predicate with the values given to us
                            // by the user predicate.
                            Hashtable newenv = (Hashtable)c.env.Clone();
                            if (t.Object is Variable)
                            {
                                unify(value, null, t.Object, newenv, true);
                            }
                            for (int i = 0; i < args.Length; i++)
                            {
                                if (unifyResult[i] != null)
                                {
                                    unify(args[i], null, unifyResult[i], newenv, true);
                                }
                            }

                            Statement grnd = evaluate(t, newenv);
                            if (grnd != Statement.All)                             // sometimes not representable, like if literal as subject
                            {
                                g.Add(new Ground(new Sequent(grnd, new Statement[0], null), new Hashtable()));
                            }

                            QueueItem r = new QueueItem();
                            r.rule   = c.rule;
                            r.src    = c.src;
                            r.ind    = c.ind;
                            r.parent = c.parent;
                            r.env    = newenv;
                            r.ground = g;
                            r.ind++;
                            queue.Add(r);

                            // Note: Since we are putting something back in for c, we don't touch the life counter on the parent.
                        }
                        else
                        {
                            // If the predicate fails, decrement the life of the parent.
                            if (c.parent != null)
                            {
                                decrementLife(c.parent, cached_subproofs);
                            }
                        }
                        continue;
                    }

                    // t can be proved either by the use of a rule
                    // or if t literally exists in the world

                    Statement t_resolved = evaluate(t, c.env);

                    // If resolving this statement requires putting a literal in subject or predicate position, we
                    // can't prove it.
                    if (t_resolved == Statement.All)
                    {
                        if (c.parent != null)
                        {
                            decrementLife(c.parent, cached_subproofs);
                        }
                        continue;
                    }

                    ArrayList tcases = new ArrayList();

                    // See if we have already tried to prove this.
                    if (cached_subproofs.ContainsKey(t_resolved))
                    {
                        StatementList cached_solutions = (StatementList)cached_subproofs[t_resolved];
                        if (cached_solutions == null)
                        {
                            if (Debug)
                            {
                                Console.Error.WriteLine("Euler: Dropping queue item because we have already failed to prove it: " + t_resolved);
                            }
                        }
                        else
                        {
                            foreach (Statement s in cached_solutions)
                            {
                                if (Debug)
                                {
                                    Console.Error.WriteLine("Euler: Using Cached Axiom:  " + s);
                                }
                                Sequent seq = new Sequent(s);
                                tcases.Add(seq);
                            }
                        }
                    }
                    else
                    {
                        // get all of the rules that apply to the predicate in question
                        if (t_resolved.Predicate != null && cases.ContainsKey(t_resolved.Predicate))
                        {
                            tcases.AddRange((IList)cases[t_resolved.Predicate]);
                        }

                        if (cases.ContainsKey("WILDCARD"))
                        {
                            tcases.AddRange((IList)cases["WILDCARD"]);
                        }

                        // if t has no unbound variables and we've matched something from
                        // the axioms, don't bother looking at the world, and don't bother
                        // proving it any other way than by the axiom.
                        bool lookAtWorld = true;
                        foreach (Sequent seq in tcases)
                        {
                            if (seq.body.Length == 0 && seq.head == t_resolved)
                            {
                                lookAtWorld = false;
                                tcases.Clear();
                                tcases.Add(seq);
                                break;
                            }
                        }

                        // if there is a seprate world, get all of the world
                        // statements that witness t
                        if (world != null && lookAtWorld)
                        {
                            MemoryStore w = new MemoryStore();

                            if (Debug)
                            {
                                Console.Error.WriteLine("Running " + c);
                            }
                            if (Debug)
                            {
                                Console.Error.WriteLine("Euler: Ask World: " + t_resolved);
                            }
                            world.Select(t_resolved, w);
                            foreach (Statement s in w)
                            {
                                if (Debug)
                                {
                                    Console.Error.WriteLine("Euler: World Select Response:  " + s);
                                }
                                Sequent seq = new Sequent(s);
                                tcases.Add(seq);
                            }
                        }
                    }

                    // If there is no evidence or potential evidence (i.e. rules)
                    // for t, then we will dump this QueueItem by not queuing any
                    // subproofs.

                    // Otherwise we try each piece of evidence in turn.
                    foreach (Sequent rl in tcases)
                    {
                        ArrayList g2 = (ArrayList)c.ground.Clone();
                        if (rl.body.Length == 0)
                        {
                            g2.Add(new Ground(rl, new Hashtable()));
                        }

                        QueueItem r = new QueueItem();
                        r.rule   = rl;
                        r.src    = rl;
                        r.ind    = 0;
                        r.parent = c;
                        r.env    = new Hashtable();
                        r.ground = g2;

                        if (unify(t, c.env, rl.head, r.env, true))
                        {
                            QueueItem ep = c;                              // euler path
                            while ((ep = ep.parent) != null)
                            {
                                if (ep.src == c.src && unify(ep.rule.head, ep.env, c.rule.head, c.env, false))
                                {
                                    break;
                                }
                            }
                            if (ep == null)
                            {
                                // It is better for caching subproofs to work an entire proof out before
                                // going on, which means we want to put the new queue item at the
                                // top of the stack.
                                queue.Add(r);
                                c.liveChildren++;
                                if (Debug)
                                {
                                    Console.Error.WriteLine("Euler: Queue from Axiom: " + r);
                                }
                            }
                        }
                    }

                    // If we did not add anything back into the queue for this item, then
                    // we decrement the life of the parent.
                    if (c.liveChildren == 0 && c.parent != null)
                    {
                        decrementLife(c.parent, cached_subproofs);
                    }
                }
            }

            return(evidence);
        }
Example #48
0
        public Error[] PreCommit(RepositoryFile file)
        {
            // Check files that have the proper extension
            // but skip the files that are deleted
            if (file.ContentsStatus == RepositoryStatus.Deleted ||
                Array.IndexOf(extensions, file.Extension) == -1)
            {
                return(Error.NoErrors);
            }

            // Skip AssemblyInfo.cs, it is a special
            // case file and should not be necessary
            // to add the header to. I think?
            if (file.FileName == "AssemblyInfo.cs")
            {
                return(Error.NoErrors);
            }

            ArrayList errors = new ArrayList();

            using (Stream stream = file.GetContents())
                using (TextReader reader = new StreamReader(stream))
                {
                    String line;
                    int    index = 0;
                    while ((line = reader.ReadLine()) != null &&
                           index < LINES.Length)
                    {
                        line = Trim(line);

                        if (line == String.Empty)
                        {
                            if (index != 0)
                            {
                                AddError(errors, file, "Blank lines are not allowed in the Apache License 2.0 header");
                            }

                            continue;
                        }

                        if (line != LINES[index])
                        {
                            if (index == 0)
                            {
                                AddError(errors, file, "No text or code is allowed before the Apache License 2.0 header");
                                continue;
                            }
                            AddError(errors, file, "Apache License 2.0 header has errors on line " + (index + 1));
                        }

                        index++;
                    }

                    // if index is still at 0 we havent found the
                    // header at all, clear the errors and add
                    // that as error.
                    if (index == 0)
                    {
                        errors.Clear();
                        AddError(errors, file, "Apache License 2.0 header is missing or there are errors on the first line");
                    }
                }

            return((Error[])errors.ToArray(typeof(Error)));
        }
Example #49
0
    private ArrayList getParameterList()
    {
        #region 前置檢查與參數過濾
        string txt_STAcceptDate = this.SLP_STAcceptDate.Text;

        string txt_TRANS_NO_S = this.SLP_TRANS_NO_S.Text;
        string txt_TRANS_NO_E = this.SLP_TRANS_NO_E.Text;

        string txt_TRUCK_NO_S = this.TRUCK_NO_S.Text;
        string txt_TRUCK_NO_E = this.TRUCK_NO_E.Text;

        string txt_SHIFT_TYPE = this.SLP_SHIFT_TYPE.Text;
        string txt_DRIVER = this.DRIVER.Text;
        string txt_TRUCK_TYPE = this.SLP_TRUCK_TYPE.Text;

        string txt_ARRIVE_TIME_S = this.SLP_ARRIVE_TIME.StartTime;
        string txt_ARRIVE_TIME_E = this.SLP_ARRIVE_TIME.EndTime;

        string txt_LEAVE_TIME_S = this.SLP_LEAVE_TIME.StartTime;
        string txt_LEAVE_TIME_E = this.SLP_LEAVE_TIME.EndTime;

        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();
        returnList.Add(GetValueSetParameter(txt_STAcceptDate, "string"));
        returnList.Add(GetValueSetParameter(txt_TRANS_NO_S, "string"));
        returnList.Add(GetValueSetParameter(txt_TRANS_NO_E, "string"));
        returnList.Add(GetValueSetParameter(txt_TRUCK_NO_S, "string"));
        returnList.Add(GetValueSetParameter(txt_TRUCK_NO_E, "string"));
        returnList.Add(GetValueSetParameter(txt_SHIFT_TYPE, "int"));
        returnList.Add(GetValueSetParameter(txt_DRIVER, "string"));
        returnList.Add(GetValueSetParameter(txt_TRUCK_TYPE, "int"));
        returnList.Add(GetValueSetParameter(txt_ARRIVE_TIME_S, "string"));
        returnList.Add(GetValueSetParameter(txt_ARRIVE_TIME_E, "string"));
        returnList.Add(GetValueSetParameter(txt_LEAVE_TIME_S, "string"));
        returnList.Add(GetValueSetParameter(txt_LEAVE_TIME_E, "string"));
        #endregion

        return returnList;

    }
Example #50
0
    void Update()
    {

        // for intersection checking sample points
        if (_segments.Count > 2)
        {
            //Debug.Log("Segment intersection test begin!");

            Vector3 pos3 = transform.transform.position;
            Vector2 pos = new Vector2(pos3.x, pos3.y);
            Vector2 end = ((LineSegment)_segments[_segments.Count - 1]).pos;

            Vector2 aabb_min, aabb_max;

            if (end.x < pos.x)
            {
                aabb_min.x = end.x;
                aabb_max.x = pos.x;
            }
            else
            {
                aabb_min.x = pos.x;
                aabb_max.x = end.x;
            }

            if (end.y < pos.y)
            {
                aabb_min.y = end.y;
                aabb_max.y = pos.y;
            }
            else
            {
                aabb_min.y = pos.y;
                aabb_max.y = end.y;
            }

            for (int i = 0; i < _segments.Count - 2; ++i)
            {
                LineSegment seg = (LineSegment)_segments[i];
                if (seg.IntersectP(aabb_min, aabb_max))
                {
                    CreatePolygon(pos, i + 1);
                    break;
                }
            }
        }








        if (emit && emitTime != 0)
        {
            emitTime -= Time.deltaTime;
            if (emitTime == 0) emitTime = -1;
            if (emitTime < 0) emit = false;
        }

        if (!emit && points.Count == 0 && autoDestruct)
        {
            Destroy(o);
            Destroy(gameObject);
        }

        // early out if there is no camera
        if (!Camera.main) return;

        bool re = false;

        // if we have moved enough, create a new vertex and make sure we rebuild the mesh
        float theDistance = (lastPosition - transform.position).magnitude;
        if (emit)
        {
            if (theDistance > minVertexDistance)
            {
                bool make = false;
                if (points.Count < 3)
                {
                    make = true;
                }
                else
                {
                    Vector3 l1 = ((Point)points[points.Count - 2]).position - ((Point)points[points.Count - 3]).position;
                    Vector3 l2 = ((Point)points[points.Count - 1]).position - ((Point)points[points.Count - 2]).position;
                    if (Vector3.Angle(l1, l2) > maxAngle || theDistance > maxVertexDistance) make = true;
                }

                if (make)
                {
                    Point p = new Point();
                    p.position = transform.position;
                    p.timeCreated = Time.time;
                    points.Add(p);
                    lastPosition = transform.position;

                    AddSegmentsPoints(transform.position);
                }
                else
                {
                    ((Point)points[points.Count - 1]).position = transform.position;
                    ((Point)points[points.Count - 1]).timeCreated = Time.time;
                }
            }
            else if (points.Count > 0)
            {
                ((Point)points[points.Count - 1]).position = transform.position;
                ((Point)points[points.Count - 1]).timeCreated = Time.time;
            }
        }

        if (!emit && lastFrameEmit && points.Count > 0) ((Point)points[points.Count - 1]).lineBreak = true;
        lastFrameEmit = emit;

        // approximate if we should rebuild the mesh or not
        if (points.Count > 1)
        {
            Vector3 cur1 = Camera.main.WorldToScreenPoint(((Point)points[0]).position);
            lastCameraPosition1.z = 0;
            Vector3 cur2 = Camera.main.WorldToScreenPoint(((Point)points[points.Count - 1]).position);
            lastCameraPosition2.z = 0;

            float distance = (lastCameraPosition1 - cur1).magnitude;
            distance += (lastCameraPosition2 - cur2).magnitude;

            if (distance > movePixelsForRebuild || Time.time - lastRebuildTime > maxRebuildTime)
            {
                re = true;
                lastCameraPosition1 = cur1;
                lastCameraPosition2 = cur2;
            }
        }
        else
        {
            re = true;
        }


        if (re)
        {
            lastRebuildTime = Time.time;

            ArrayList remove = new ArrayList();
            //ArrayList remove_seg = new ArrayList();
            int i = 0;
            foreach (Point p in points)
            {
                bool add = false;
                // cull old points first
                if (p.dead && Time.time - p.transTime > deadTime) add = true;
                else if (p.highlight && Time.time - p.transTime > highlightTime) add = true;
                else if (Time.time - p.timeCreated > lifeTime) add = true;

                if (add)
                {
                    remove.Add(p);
                    //remove_seg.Add(_segments[i]);
                }
                i++;
            }

            foreach (Point p in remove) points.Remove(p);
            remove.Clear();

            //foreach (LineSegment s in remove_seg) _segments.Remove(s);
            //remove_seg.Clear();

            if (points.Count > 1)
            {
                Vector3[] newVertices = new Vector3[points.Count * 2];
                Vector2[] newUV = new Vector2[points.Count * 2];
                int[] newTriangles = new int[(points.Count - 1) * 6];
                Color[] newColors = new Color[points.Count * 2];

                i = 0;
                float curDistance = 0.00f;

                foreach (Point p in points)
                {
                    float time = (Time.time - p.timeCreated) / lifeTime;
                    time = time * 0.5f + 0.5f;
                    if (p.dead && p.transTime + deadTime < p.timeCreated + lifeTime)
                    {
                        time = (p.transTime - p.timeCreated) / lifeTime + (Time.time - p.transTime) / deadTime;
                        time = time * 0.5f + 0.5f;
                    }
                    else if (p.highlight)
                    {
                        time = (Time.time - p.transTime) / highlightTime;
                        if (time > 1) time = 1f;
                    }
                    

                    Color color = Color.Lerp(Color.white, Color.clear, time);
                    if (colors != null && colors.Length > 0)
                    {
                        float colorTime = time * (colors.Length - 1);
                        float min = Mathf.Floor(colorTime);
                        float max = Mathf.Clamp(Mathf.Ceil(colorTime), 1, colors.Length - 1);
                        float lerp = Mathf.InverseLerp(min, max, colorTime);
                        if (min >= colors.Length) min = colors.Length - 1; if (min < 0) min = 0;
                        if (max >= colors.Length) max = colors.Length - 1; if (max < 0) max = 0;
                        color = Color.Lerp(colors[(int)min], colors[(int)max], lerp);
                    }

                    float size = 1f;
                    if (sizes != null && sizes.Length > 0)
                    {
                        float sizeTime = time * (sizes.Length - 1);
                        float min = Mathf.Floor(sizeTime);
                        float max = Mathf.Clamp(Mathf.Ceil(sizeTime), 1, sizes.Length - 1);
                        float lerp = Mathf.InverseLerp(min, max, sizeTime);
                        if (min >= sizes.Length) min = sizes.Length - 1; if (min < 0) min = 0;
                        if (max >= sizes.Length) max = sizes.Length - 1; if (max < 0) max = 0;
                        size = Mathf.Lerp(sizes[(int)min], sizes[(int)max], lerp);
                    }

                    Vector3 lineDirection = Vector3.zero;
                    if (i == 0) lineDirection = p.position - ((Point)points[i + 1]).position;
                    else lineDirection = ((Point)points[i - 1]).position - p.position;

                    Vector3 vectorToCamera = Camera.main.transform.position - p.position;
                    Vector3 perpendicular = Vector3.Cross(lineDirection, vectorToCamera).normalized;

                    newVertices[i * 2] = p.position + (perpendicular * (size * 0.5f));
                    newVertices[(i * 2) + 1] = p.position + (-perpendicular * (size * 0.5f));

                    newColors[i * 2] = newColors[(i * 2) + 1] = color;

                    newUV[i * 2] = new Vector2(curDistance * uvLengthScale, 0);
                    newUV[(i * 2) + 1] = new Vector2(curDistance * uvLengthScale, 1);

                    if (i > 0 && !((Point)points[i - 1]).lineBreak)
                    {
                        if (higherQualityUVs) curDistance += (p.position - ((Point)points[i - 1]).position).magnitude;
                        else curDistance += (p.position - ((Point)points[i - 1]).position).sqrMagnitude;

                        newTriangles[(i - 1) * 6] = (i * 2) - 2;
                        newTriangles[((i - 1) * 6) + 1] = (i * 2) - 1;
                        newTriangles[((i - 1) * 6) + 2] = i * 2;

                        newTriangles[((i - 1) * 6) + 3] = (i * 2) + 1;
                        newTriangles[((i - 1) * 6) + 4] = i * 2;
                        newTriangles[((i - 1) * 6) + 5] = (i * 2) - 1;
                    }

                    i++;
                }

                Mesh mesh = (o.GetComponent(typeof(MeshFilter)) as MeshFilter).mesh;
                mesh.Clear();
                mesh.vertices = newVertices;
                mesh.colors = newColors;
                mesh.uv = newUV;
                mesh.triangles = newTriangles;
            }
        }
    }
        public ArrayList getPalabraLarga(String texto)
        {
            ArrayList palabraLarga     = new ArrayList();
            int       palabraLargaCont = 0;
            //lista para almacenar una palabra
            ArrayList palabra = new ArrayList();

            //cadena de chars para formar una palabra
            Char[] palabraArray;
            String resultado;
            //verifica si la palabra ya se ha guardado
            Boolean palGuardada = false;
            //convierte el string a cadena de chars
            var chars = texto.ToCharArray();

            //ciclo que recorre la cadena de chars
            foreach (char letra in chars)
            {
                //verifica que se a una letra
                if (Char.IsLetterOrDigit(letra) == false)
                {
                    //crea un arreglo de la cantidad de chars de la palabra
                    palabraArray = new char[palabra.Count];
                    //pasa los chars a una lista
                    palabra.CopyTo(palabraArray);
                    //se une la palabra formada
                    resultado = string.Join(null, palabraArray);

                    //funcion palabra mas larga
                    if (palabra.Count > palabraLargaCont)
                    {
                        palabraLarga.Clear();
                        palabraLarga.Add(resultado);
                        palabraLargaCont = resultado.Length;
                    }
                    else if (palabra.Count == palabraLargaCont)
                    {
                        if (!palabraLarga.Contains(resultado))
                        {
                            palabraLarga.Add(resultado);
                        }
                    }

                    //se setean los valores
                    palabra     = new ArrayList();
                    palGuardada = true;
                }
                else
                {
                    //agrega chars a la lista para conformar una palabra
                    palabra.Add(letra);
                    palGuardada = false;
                }
            }
            //verifica que la palabra se haya guardado
            if (palGuardada == false)
            {
                palabraArray = new char[palabra.Count];
                palabra.CopyTo(palabraArray);
                resultado = string.Join(null, palabraArray);
                //funcion palabra mas larga
                if (palabra.Count > palabraLargaCont)
                {
                    palabraLarga.Clear(); palabraLarga.Add(resultado);
                }
                else if (palabra.Count == palabraLargaCont)
                {
                    palabraLarga.Add(resultado);
                }
                palabra = new ArrayList();
            }
            return(palabraLarga);
        }
Example #52
0
        public float GetCutDistance(ArrayList notes)
        {
            float     totalDistance       = 0f;
            Vector2   bladePos            = new Vector2(1.5f, 1.5f); // start at center
            ArrayList notesAtThisTimeStep = new ArrayList();

            for (int i = 0; i < notes.Count; i++)
            {
                notesAtThisTimeStep.Clear();

                // find all notes at this notes time step
                float currentNoteTime  = ((Note)notes[i]).time;
                float previousNoteTime = -1;
                float nextNoteTime     = -1;

                if (i != 0)
                {
                    previousNoteTime = BeatsToSeconds(((Note)notes[i - 1]).time);
                }
                if (i != notes.Count - 1)
                {
                    nextNoteTime = BeatsToSeconds(((Note)notes[i + 1]).time);
                }

                //Nerf Streams
                if (previousNoteTime != -1 && nextNoteTime != -1)
                {
                    float timeBetween = nextNoteTime - previousNoteTime;
                    if (timeBetween < 0.35f)
                    {
                        cutLeadDistance   = 1f;
                        cutFollowDistance = 0.5f; //we're in a stream
                    }
                    else
                    {
                        cutLeadDistance   = 2f;
                        cutFollowDistance = 1f;
                    }
                }

                int j = 0;
                while (((Note)notes[i + j]).time == currentNoteTime)
                {
                    notesAtThisTimeStep.Add(((Note)notes[i + j]));
                    j++;
                    if (i + j >= notes.Count)
                    {
                        break;
                    }
                }

                i += j - 1; // don't count these notes again

                if (notesAtThisTimeStep.Count > 1)
                {
                    // solve group of notes
                    totalDistance += CutNotesWithBlade(notesAtThisTimeStep, ref bladePos);
                }
                else
                {
                    // one note only
                    Note note = (Note)notesAtThisTimeStep[0];
                    totalDistance += CutNoteWithBlade(note, ref bladePos);
                }
            }

            return(totalDistance);
        }
Example #53
0
 public void Clear()
 {
     mStrings.Clear();
     mStringsLive = true;
 }
Example #54
0
 public void RemoveAll()
 {
     dataSeriesList.Clear();
 }
    }//Page_Load

    private void QueryData()
    {
        #region
        DataTable dt = null;
        string SessionIDName = string.Format("{0}_{1}", strPrefixed, PageTimeStamp.Value);

        if (dtTransPayRoute != null)
        {
            DataView dv = dtTransPayRoute.DefaultView;
            dv.RowFilter = string.Format("TRANS_NO = '{0}' and PAY_NO ='{1}'", s_TRANS_NO, s_PAY_NO);
            dt = dv.ToTable();
        }

        if (dt == null)
        {
            TRNModel.VDS_TRN13_BCO BCO = new TRNModel.VDS_TRN13_BCO(ConnectionDB);
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(s_TRANS_NO);
            ParameterList.Add(s_PAY_NO);
            dt = BCO.QUERY_TRANS_PAY_ROUTE(ParameterList);
        }

        bAfterQueryDataBinding = true;

        if (!dt.Columns.Contains("CHECKED"))//增加欄位以方便判別是否可
            dt.Columns.Add("CHECKED");

        if (!dt.Columns.Contains("ROWID"))//增加欄位以判別勾選與否
            dt.Columns.Add("ROWID");

        if (!dt.Columns.Contains("CODE"))//增加欄位以判別勾選與否
            dt.Columns.Add("CODE");

        if (!dt.Columns.Contains("ROWNUM"))//增加欄位以判別勾選與否
            dt.Columns.Add("ROWNUM");


        hidden_RowID_MaxID.Value = dt == null ? "-1" : (dt.Rows.Count - 1).ToString();//記錄最大ROWID
        hidden_RowID_Selected.Value = "";//清空已選ROWID

        Session[SessionIDName] = dt;


        SetRowIDToDataTable(true);//設定ROWID

        GridView1.DataSource = dt;
        GridView1.PageSize = 20;
        GridView1.DataBind();
        GridView1.SelectedIndex = -1;
        
        bAfterQueryDataBinding = false;

        if (dt == null || (dt != null && dt.Rows.Count <= 0))
        {
            ErrorMsgLabel.Text = "查無資料";
        }
        #endregion
    }
Example #56
0
 //----------- void ClearMessages() ------------------------------
 // Clears the messages from the screen and the lists
 //---------------------------------------------------------------
 public void ClearMessages()
 {
     messages.Clear();
     colors.Clear();
     ClearScreen();
 }
Example #57
0
        public void ProcessRequest(HttpContext context)
        {
            //判断客户端请求是否为post方法
            if (context.Request.HttpMethod.ToUpper() != "POST")
            {
                context.Response.Write("{\"errmsg\":\"请求方式不允许,请使用POST方式(DD0001)\",\"errcode\":1}");
                return;
            }
            string ymadk = System.Configuration.ConfigurationManager.AppSettings["ymadk"].ToString() + "/";

            //数据库链接
            connectionString = ToolsClass.GetConfig("DataOnLine");

            da = new DbHelper.SqlHelper("SqlServer", connectionString);
            string signUrl = ToolsClass.GetConfig("signUrl"); context.Response.ContentType = "text/plain";

            //获取请求json
            using (var reader = new StreamReader(context.Request.InputStream, Encoding.UTF8))
            {
                CsJson = reader.ReadToEnd();
            }

            Object    jgobj      = ToolsClass.DeserializeObject(CsJson);
            Hashtable returnhash = jgobj as Hashtable;

            if (CsJson == "")
            {
                context.Response.Write("{\"errmsg\":\"报文格式错误(DD0003)\",\"errcode\":1}");
                return;
            }

            CsJson = Regex.Replace(CsJson, @"[\n\r]", "").Replace(@"\n", ",").Replace("'", "‘").Replace("\t", ":").Replace("\r", ",").Replace("\n", ",");

            ToolsClass.TxtLog("审批信息修改日志", context.Request.Path.ToLower() + "\r\n修改后的数据:" + CsJson + "\r\n");

            string path1 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeclfbxdetails");
            string path2 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeqitadetails");
            string path3 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changezddetails");
            string path4 = context.Request.Path.Replace("Approval/ChangeSQDetails.ashx", "changeqtfydetails");
            //验证请求sign
            string sign1 = ToolsClass.md5(signUrl + path1 + "Romens1/DingDing2" + path1, 32);
            string sign2 = ToolsClass.md5(signUrl + path2 + "Romens1/DingDing2" + path2, 32);
            string sign3 = ToolsClass.md5(signUrl + path3 + "Romens1/DingDing2" + path3, 32);
            string sign4 = ToolsClass.md5(signUrl + path4 + "Romens1/DingDing2" + path4, 32);

            ToolsClass.TxtLog("生成的sign", "生成的" + "sign:" + sign1 + ";" + sign2 + ";" + sign3 + ";" + sign4 + ";" + "传入的sign" + returnhash["Sign"].ToString() + "\r\n");

            if (sign1 != returnhash["Sign"].ToString() && sign2 != returnhash["Sign"].ToString() && sign3 != returnhash["Sign"].ToString() && sign4 != returnhash["Sign"].ToString())
            {
                context.Response.Write("{\"errmsg\":\"认证信息Sign不存在或者不正确!\",\"errcode\":1}");
                return;
            }
            try
            {
                if (returnhash["BillNo"].ToString().Contains("CL"))
                {
                    //前端传入数据
                    changeCLFBXSQRC = new ChangeCLFBXSQRC();
                    changeCLFBXSQRC = (ChangeCLFBXSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeCLFBXSQRC));

                    isclf = 1;
                }
                else if (returnhash["BillNo"].ToString().Contains("TXF") || returnhash["BillNo"].ToString().Contains("JTF"))
                {
                    //前端传入数据
                    changeQTSQRC = new ChangeQTSQRC();
                    changeQTSQRC = (ChangeQTSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeQTSQRC));

                    isclf = 2;
                }
                else if (returnhash["BillNo"].ToString().Contains("ZDF"))
                {
                    //前端传入数据
                    changeZDSQRC = new ChangeZDSQRC();
                    changeZDSQRC = (ChangeZDSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeZDSQRC));

                    isclf = 3;
                }
                else if (returnhash["BillNo"].ToString().Contains("QTFY"))
                {
                    //前端传入数据
                    changeQTFYSQRC = new ChangeQTFYSQRC();
                    changeQTFYSQRC = (ChangeQTFYSQRC)JsonConvert.DeserializeObject(CsJson, typeof(ChangeQTFYSQRC));

                    isclf = 4;
                }
                string updatedetail    = "";
                string updateCCnum     = "";
                string insertLogMain   = "";
                string insertLogDetail = "";

                if (isclf == 1)
                {
                    updateCCnum = $"update ExpeTrav set CCNum = CCNum -1 where billno = '{changeCLFBXSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();
                    //修改可修改次数减一
                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeCLFBXSQRC.BillType}','差旅费报销','{changeCLFBXSQRC.SPPDDid}','{changeCLFBXSQRC.SPPName}','{changeCLFBXSQRC.BillNo}','{changeCLFBXSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeTravDetailLOG(BillNo, Detailno, CustCode, DepaDate, RetuDate , DepaCity, DestCity, TranMode, TranCount, TranAmount, AlloDay,AlloPric,AlloAmount, AccoCount, AccoAmount , CityTrafCount , CityTraAmont , TotalAmount, GUID , OtherFee , GasAmount , HSRAmount , OffDay , TaxAmount , TripNo, DepaCity1, DestCity1, MAINGUID) SELECT BillNo, Detailno, CustCode, DepaDate, RetuDate , DepaCity, DestCity, TranMode, TranCount, TranAmount, AlloDay,AlloPric,AlloAmount, AccoCount, AccoAmount , CityTrafCount , CityTraAmont , TotalAmount, GUID , OtherFee , GasAmount , HSRAmount , OffDay , TaxAmount , TripNo, DepaCity1, DestCity1, '{guid}' FROM ExpeTravDetail  where  BillNo='{changeCLFBXSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);
                    sqlList.Clear();

                    #region 修改差旅费

                    //,isnull(B.TripNo,0) TripNo,convert(varchar(20),B.DepaDate,120) DepaDate,convert(varchar(20),B.RetuDate,120) RetuDate,B.DepaCity,B.DestCity,B.CustCode,e.CustName,B.DetailNo,B.AlloDay,B.OffDay,AlloPric, AlloAmount,OtherFee,B.TranMode,B.TranCount,TranAmount,GasAmount,HsrAmount,B.AccoCount,AccoAmount,B.CityTrafCount,CityTraAmont,TotalAmount
                    for (int i = 0; i < changeCLFBXSQRC.ExpeTravDetail.Length; i++)
                    {
                        double ta = 0.00;
                        ta           = double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].TranAmount) + double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].AlloAmount) + double.Parse(changeCLFBXSQRC.ExpeTravDetail[i].OtherFee);
                        updatedetail = $"update ExpeTravDetail set TranCount ='{changeCLFBXSQRC.ExpeTravDetail[i].TranCount}',TranAmount='{changeCLFBXSQRC.ExpeTravDetail[i].TranAmount}',AlloDay='{changeCLFBXSQRC.ExpeTravDetail[i].AlloDay}',AlloPric='{changeCLFBXSQRC.ExpeTravDetail[i].AlloPric}',AlloAmount='{changeCLFBXSQRC.ExpeTravDetail[i].AlloAmount}',AccoCount='{changeCLFBXSQRC.ExpeTravDetail[i].AccoCount}',AccoAmount='{changeCLFBXSQRC.ExpeTravDetail[i].AccoAmount}',CityTrafCount='{changeCLFBXSQRC.ExpeTravDetail[i].CityTrafCount}',CityTraAmont='{changeCLFBXSQRC.ExpeTravDetail[i].CityTraAmont}',TotalAmount='{ta}',OtherFee='{changeCLFBXSQRC.ExpeTravDetail[i].OtherFee}',DepaDate='{changeCLFBXSQRC.ExpeTravDetail[i].DepaDate}',RetuDate='{changeCLFBXSQRC.ExpeTravDetail[i].RetuDate}',DepaCity='{changeCLFBXSQRC.ExpeTravDetail[i].DepaCity}',DestCity='{changeCLFBXSQRC.ExpeTravDetail[i].DestCity}',GasAmount='{changeCLFBXSQRC.ExpeTravDetail[i].GasAmount}',HSRAmount='{changeCLFBXSQRC.ExpeTravDetail[i].HsrAmount}',TranMode='{changeCLFBXSQRC.ExpeTravDetail[i].TranMode}',OffDay='{changeCLFBXSQRC.ExpeTravDetail[i].OffDay}'  where BillNo = '{changeCLFBXSQRC.BillNo}' and Detailno = '{changeCLFBXSQRC.ExpeTravDetail[i].DetailNo}' and TripNo='{changeCLFBXSQRC.ExpeTravDetail[i].TripNo}'";
                        sqlTou.Clear();
                        sqlTou.Append(updatedetail);
                        sqlList.Add(sqlTou.ToString());
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }

                    string ss = da.ExecSql(sqlList);
                    da.ExecSql($"update ExpeTravDetail");
                    ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句返回:" + ss + "\r\n");
                    if (ss == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");

                    #endregion 修改差旅费
                }
                else if (isclf == 2)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeOther set CCNum = CCNum -1 where billno = '{changeQTSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeQTSQRC.BillType}','交通费、通讯费报销','{changeQTSQRC.SPPDDid}','{changeQTSQRC.SPPName}','{changeQTSQRC.BillNo}','{changeQTSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeOtherLOG(BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum, '{guid}' FROM ExpeOther  where  BillNo='{changeQTSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);

                    updatedetail = $"update ExpeOther set BillCount='{changeQTSQRC.BillCount}',FeeAmount='{changeQTSQRC.FeeAmount}'  where BillNo = '{changeQTSQRC.BillNo}'";

                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                }
                else if (isclf == 3)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeEnteMent set CCNum = CCNum -1 where billno = '{changeZDSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeZDSQRC.BillType}','招待费报销','{changeZDSQRC.SPPDDid}','{changeZDSQRC.SPPName}','{changeZDSQRC.BillNo}','{changeZDSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeEnteMentLOG( BillNo,BillDate,ApplPers,BearOrga ,CustCode ,BillCount,FeeAmount ,Notes ,OperatorGuid,IsAuditing ,AuditingGUID,AuditingDate ,IsAccount ,AccountGUID,AccountDate,REALDATE ,ISREFER ,REFERGUID ,REFERDATE ,NoCountFee,DDOperatorId,DDAuditingId,AppendixUrl,PictureUrl,SelAuditingGuid ,SelAuditingName ,CopypersonID ,CopyPersonName,IsSp ,AuditingIdea ,ProcessNodeInfo,Urls,DeptCode,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,ApplPers,BearOrga ,CustCode ,BillCount,FeeAmount ,Notes ,OperatorGuid,IsAuditing ,AuditingGUID,AuditingDate ,IsAccount ,AccountGUID,AccountDate,REALDATE ,ISREFER ,REFERGUID ,REFERDATE ,NoCountFee,DDOperatorId,DDAuditingId,AppendixUrl,PictureUrl,SelAuditingGuid ,SelAuditingName ,CopypersonID ,CopyPersonName,IsSp ,AuditingIdea ,ProcessNodeInfo,Urls,DeptCode,DeptName ,CCNum, '{guid}' FROM ExpeEnteMent  where  BillNo='{changeZDSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    da.ExecSql(sqlList);

                    updatedetail = $"update ExpeEnteMent set BillCount='{changeZDSQRC.BillCount}',FeeAmount='{changeZDSQRC.FeeAmount}'  where BillNo = '{changeZDSQRC.BillNo}'";

                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }

                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改单据明细:{updatedetail} \r\n  修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                }
                else if (isclf == 4)
                {
                    //修改可修改次数减一
                    updateCCnum = $"update ExpeOther set CCNum = CCNum -1 where billno = '{changeQTFYSQRC.BillNo}'";
                    string guid = Guid.NewGuid().ToString();

                    //保存修改的日志内容
                    insertLogMain   = $"insert into BILLCHANGELOG(GUID,BILLTYPE,BILLNAME,DDID,SPPName,BILLNO,ChangeReason)  values('{guid}','{changeQTFYSQRC.BillType}','其他费用报销','{changeQTFYSQRC.SPPDDid}','{changeQTFYSQRC.SPPName}','{changeQTFYSQRC.BillNo}','{changeQTFYSQRC.ChangeReason}')";
                    insertLogDetail = $"INSERT INTO ExpeOtherLOG(BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum,MAINGUID) SELECT BillNo,BillDate,FeeType ,ApplPers,BearOrga,BillCount,FeeAmount,Notes ,OperatorGuid,IsAuditing ,AuditingGUID ,AuditingDate,IsAccount ,AccountGUID ,AccountDate,REALDATE,ISREFER,REFERGUID,REFERDATE ,NoCountFee ,DDOperatorId,DDAuditingId ,AppendixUrl ,PictureUrl ,SelAuditingGuid ,SelAuditingName,CopypersonID ,CopyPersonName ,IsSp ,AuditingIdea,ProcessNodeInfo,Urls,DeptCode ,DeptName ,CCNum, '{guid}' FROM ExpeOther  where  BillNo='{changeQTFYSQRC.BillNo}'";

                    sqlList.Clear();
                    sqlList.Add(updateCCnum);
                    sqlList.Add(insertLogMain);
                    sqlList.Add(insertLogDetail);
                    ToolsClass.TxtLog("审批信息修改日志", $"\r\n 修改可修改次数:{updateCCnum}  \r\n    保存日志主表:{insertLogMain} \r\n   保存日志明细:{insertLogDetail}");
                    da.ExecSql(sqlList);

                    sqlList.Clear();
                    for (int i = 0; i < changeQTFYSQRC.OtherCostSQModels.Count; i++)
                    {
                        updatedetail = $"insert into ExpeOtherDetailLOG(BillNo,MAINGUID,BillCount,BillAmount,FeeTypeDetail) values('{changeQTFYSQRC.BillNo}','{guid}','{changeQTFYSQRC.OtherCostSQModels[i].Count}','{changeQTFYSQRC.OtherCostSQModels[i].Amount}','{changeQTFYSQRC.OtherCostSQModels[i].FType}')";
                        sqlList.Add(updatedetail);
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }
                    da.ExecSql(sqlList);
                    sqlList.Clear();
                    updatedetail = $"update ExpeOther set BillCount='{changeQTFYSQRC.BillCount}',FeeAmount='{changeQTFYSQRC.FeeAmount}'  where BillNo = '{changeQTFYSQRC.BillNo}'";
                    da.ExecSql(updatedetail);
                    ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    for (int i = 0; i < changeQTFYSQRC.OtherCostSQModels.Count; i++)
                    {
                        updatedetail = string.Empty;
                        updatedetail = $"update ExpeOtherDetail set BillCount ='{changeQTFYSQRC.OtherCostSQModels[i].Count}',BillAmount='{changeQTFYSQRC.OtherCostSQModels[i].Amount}'  where BillNo = '{changeQTFYSQRC.BillNo}' and FeeTypeDetail = '{changeQTFYSQRC.OtherCostSQModels[i].FType}'";
                        sqlTou.Clear();
                        sqlTou.Append(updatedetail);
                        sqlList.Add(sqlTou.ToString());
                        ToolsClass.TxtLog("审批信息修改日志", "\r\n执行的sql语句:" + updatedetail + "\r\n");
                    }
                    da.ExecSql(sqlList);
                    if (da.ExecSql(updatedetail) == null)
                    {
                        context.Response.Write("{\"errmsg\":\"更新流程失败\",\"errcode\":1}");
                        return;
                    }
                }
                context.Response.Write("{\"errmsg\":\"ok\",\"errcode\":0}");
                return;
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"errmsg\":\"" + ex.Message + "\",\"errcode\":1}");
                context.Response.End();
            }
        }
Example #58
0
 /**
  * Retrieves all opportunity IDs from the Database. This should not be used
  * with large databases - if possible, replace this with a function to
  * retrieve the opportunities in large chunks as needed.
  */
 static public bool get_all_opportunities()
 {
     cached_opportunities.Clear();
     cached_opportunities = Database.get_all_opportunities(storedUserName, storedPassword);
     return(true);
 }
Example #59
0
    /// <summary>
    /// 取得商品儲區擷轉明細
    /// </summary>
    private DataTable QueryData()
    {
        #region
        #region 傳入參數

        ArrayList ParameterList = new ArrayList();

        ParameterList.Clear();
        ParameterList.Add(GetValueSetParameter(slp_TRANS_DATE.Text, "date", false));
        ParameterList.Add(GetValueSetParameter(slp_ST_ACCEPT_DATE.Text, "date", false));
        ParameterList.Add(GetValueSetParameter(SLP_RootNo1.Text.Trim(), "int", false));
        ParameterList.Add(GetValueSetParameter(slp_IS_OVERDUE.SelectedValue, "int", false));
        ParameterList.Add(GetValueSetParameter(txt_TRANS_NO_B.Text, "string", false));
        ParameterList.Add(GetValueSetParameter(txt_TRANS_NO_E.Text, "string", false));
        ParameterList.Add(Session["UID"].ToString());

        if (!IsPostBack)
        {
            ParameterList.Add(GetValueSetParameter("9999", "int", false));
        }
        else
        {
            ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text.Trim(), "int", false));
        }

        #endregion

        #region 取得資料

        DataTable dt_Return = new DataTable();

        BCO.QueryCRMCommon bco = new BCO.QueryCRMCommon(ConntionDB);

        try
        {
            dt_Return = bco.QUERY_NON_TRANSDATA(ParameterList);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion

        #region 資料與GridView繫結
        string SessionIDName = "CRM071A_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt_Return;
        this.gv_TransErrData.DataSource = dt_Return;
        this.gv_TransErrData.PageSize = (this.TextBoxPagesize.Text == string.Empty) ? 10 : (int.Parse(this.TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(this.TextBoxPagesize.Text);
        this.gv_TransErrData.PageIndex = 0;
        this.gv_TransErrData.DataBind();

        #endregion

        return dt_Return;
        #endregion
    }
Example #60
0
 private void button1_Click(object sender, EventArgs e)
 {
     textBox1.Text = "";
     list.Clear();
     attack = 0;
 }