2015年11月7日 星期六

VHD to OVA Convert

搞了好多天,最後是很簡單的下載了visualbox來做轉檔的工具!!!

2015年10月29日 星期四

CentOS OCS-Server

參考來源

1.Make utility
yum groupinstall Development Tools

2.必須安裝與Perl相關的套件
yum install mod_perl

3.安裝Perl的XML支援套件
yum install perl-XML-Simple

4.安裝Perl的壓縮管理支援套件
yum install perl-Compress-Zlib

5.安裝Perl的DBI支援套件
yum install perl-Apache-DBI

6.安裝Perl的DBI支援套件
yum install perl-DBI

7.安裝Perl的Net-IP支援套件
yum install perl-Net-IP

8.安裝的是Perl的SOAP-Lite支援套件
yum install perl-SOAP-Lite

9.
如果想要查看目前所使用的Perl版本,只要如圖3所示下達命令「perl -v」即可
也可以直接下
yum install mod_perl perl-XML-Simple perl-Compress-Zlib perl-DBI perl-DBD-MySQL perl-Apache-DBI perl-Net-IP perl-SOAP-Lite php-pecl-zip php-mysql php-devel zlib-devel php-pear php-gd gcc php-mbstring

10.必須加裝與PHP相關的套件
yum install php-pecl-zip

11.加裝php-gd套件
yum install php-gd

12.
去ocs官網下載server檔

13.
解壓之後,以終端機開啟資料夾

14.執行安裝
sh setup.sh

15.
都採預設即可

16.
如果mod_perl是在OCSNG伺服器安裝設定之後才安裝,可能會導致httpd服務無法啟動,此時必須重新執行一次OCSNG伺服器設定

17.這次安裝之後出現apache掛了的訊息。
[root@localhost ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
   Active: failed (Result: exit-code) since 一 2015-11-02 21:23:21 CST; 54s ago
  Process: 4175 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 4173 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 4173 (code=exited, status=1/FAILURE)

11月 02 21:23:21 localhost.localdomain httpd[4173]: AH00526: Syntax error on line 38 of /etc/httpd/conf.d/ocsinventory-reports.conf:
11月 02 21:23:21 localhost.localdomain httpd[4173]: Invalid command 'php_flag', perhaps misspelled or defined by a module not incl...ration
11月 02 21:23:21 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
11月 02 21:23:21 localhost.localdomain kill[4175]: kill: cannot find process ""
11月 02 21:23:21 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
11月 02 21:23:21 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
11月 02 21:23:21 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.

Hint: Some lines were ellipsized, use -l to show in full.
結果重新安裝php就可以了。
yum install php

18.

Centos7 安裝mariadb

參考來源

#yum install mariadb mariadb-server =>安裝
#systemctl start mariadb.service =>啟動服務
#systemctl enable mariadb.service =>設定開機啟動服務
#mysql_secure_installation =>進入初始設定
Enter current password for root (enter for none): #輸入目前MariaDB 的root密碼(第一次設定應該是空的,所以直接按Enter即可)
Set root password? [Y/n] Y #是否要設定新的MariaDBroot密碼?在此是按Y
New password:              #設定第一次新的MariaDB root密碼
Re-enter new password:     #設定第二次
Remove anonymous users? [Y/n] Y #是否要移除anonymous user的資料?預設是Y
... Success!
Disallow root login remotely? [Y/n]  Y #設定是否讓root只能從localhost登入,不能從其他的網路登入!(預設是Y)
Remove test database and access to it? [Y/n] Y #是否要移除test的資料庫?預設是移除
Reload privilege tables now? [Y/n]  Y #是否要重新載入權限的table資訊?預設是Y
... Success!

可連線測試
#mysql -u root -p
Enter password:你剛剛設定的密碼
MariaDB [(none)]> show databases;

讓php支援mariadb
#yum install php-mysql

Centos7 安裝 phpmyadmin

一、來源
sudo yum install epel-release


二、來源
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm



三、來源同上
# yum --enablerepo=remi,remi-test install phpMyAdmin

四、
yum install phpmyadmin

五、
打開phpmyadmin的config
/etc/httpd/conf.d/

六、
<Directory /usr/share/phpMyAdmin/>
    <IfModule !mod_authz_core.c>
     Order Deny,Allow
     Deny from All
     Allow from 192.168.1.0/24
     Allow from ::1
   </IfModule>
</Directory>

七、
service httpd restart

八、
利用網頁測試連接phpmyadmin
再用mariadb的root帳號去登入即可。

九、
也可以參考
也可以參考

2015年9月23日 星期三

2015年8月17日 星期一

ASP.NET-Dropdownlist預設值+驗證RequiredFieldValidator

參考

  •  <asp:ListItem Value="0">請選擇</asp:ListItem>
  • AppendDataBoundItems ="true"
  • 還可以弄一個驗證物件來做驗證
  • InitialValue="0" 初始值設定為0,只要是0就會跳出errormessage。

2015年8月16日 星期日

ASP.NET-Code-Behind控制div是否顯示

  • runat="server"
  • 給個id
  • divIns.Style("display") = "none"<--隱藏
  • divIns.Style("display") = "inline"<--顯示

ASP.NET-GRIDVIEW各種大小事記錄

RowDataBound

取DataKey:

GridVeiw.DataKeys(e.Row.RowIndex).Value.ToString

FindControl一定要服用:

If e.Row.RowType = DataControlRowType.DataRow Then

判斷操作模式:

If e.Row.RowState = DataControlRowState.Edit Then

FindControl:

Dim ddl As DropDownList = CType(e.Row.FindControl("ddl_PROC_KIND"), DropDownList)

偶數列無法判斷解決:

If e.Row.RowState = DataControlRowState.Edit OrElse CInt(e.Row.RowState) = 5 Then

RowCommand 

FindControl:

Dim ddl1 As DropDownList = DirectCast(DirectCast(e.CommandSource, Control).FindControl("欄位名稱"), DropDownList)

取DataKey:

  • Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, Control).NamingContainer, GridViewRow)
  • Dim pk As Integer = Convert.ToInt32(GridView.DataKeys(row.RowIndex).Values(0))
  • 如果有設定多個的話,就1、2、3

2015年7月22日 星期三

ASP.NET-如何使用CalendarExtender選擇年月

功能需求:日期區間以年月來選 。
參考來源:連結
執行畫面:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestOnlyChangeMonthAndSetDefaultDay.aspx.vb"
    Inherits="SoluTest_CalendarUserControl.TestOnlyChangeMonthAndSetDefaultDay" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var cal1;
        var cal2;
        function pageLoad() {
            cal1 = $find("calendar1");
            cal2 = $find("calendar2");
            modifyCalDelegates(cal1);
            modifyCalDelegates(cal2);
        }
        function modifyCalDelegates(cal) {
            //we need to modify the original delegate of the month cell.
            cal._cell$delegates = {
                mouseover: Function.createDelegate(cal, cal._cell_onmouseover),
                mouseout: Function.createDelegate(cal, cal._cell_onmouseout),


                click: Function.createDelegate(cal, function(e) {
                    /// <summary>
                    /// Handles the click event of a cell
                    /// </summary>
                    /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>


                    e.stopPropagation();
                    e.preventDefault();


                    if (!cal._enabled) return;


                    var target = e.target;
                    var visibleDate = cal._getEffectiveVisibleDate();
                    Sys.UI.DomElement.removeCssClass(target.parentNode, "ajax__calendar_hover");
                    switch (target.mode) {
                        case "prev":
                        case "next":
                            cal._switchMonth(target.date);
                            break;
                        case "title":
                            switch (cal._mode) {
                                case "days": cal._switchMode("months"); break;
                                case "months": cal._switchMode("years"); break;
                            }
                            break;
                        case "month":
                            //if the mode is month, then stop switching to day mode.
                            if (target.month == visibleDate.getMonth()) {
                                //this._switchMode("days");
                            } else {
                                cal._visibleDate = target.date;
                                //this._switchMode("days");
                            }
                            cal.set_selectedDate(target.date);
                            cal._switchMonth(target.date);
                            cal._blur.post(true);
                            cal.raiseDateSelectionChanged();
                            break;
                        case "year":
                            if (target.date.getFullYear() == visibleDate.getFullYear()) {
                                cal._switchMode("months");
                            } else {
                                cal._visibleDate = target.date;
                                cal._switchMode("months");
                            }
                            break;


                        //                case "day":
                        //                    this.set_selectedDate(target.date);
                        //                    this._switchMonth(target.date);
                        //                    this._blur.post(true);
                        //                    this.raiseDateSelectionChanged();
                        //                    break;
                        case "today":
                            cal.set_selectedDate(target.date);
                            cal._switchMonth(target.date);
                            cal._blur.post(true);
                            cal.raiseDateSelectionChanged();
                            break;
                    }


                })
            }


        }


        function onCalendarShown(sender, args) {
            //set the default mode to month
            sender._switchMode("months", true);
            changeCellHandlers(cal1);
        }




        function changeCellHandlers(cal) {


            if (cal._monthsBody) {


                //remove the old handler of each month body.
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        $common.removeHandlers(row.cells[j].firstChild, cal._cell$delegates);
                    }
                }
                //add the new handler of each month body.
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        $addHandlers(row.cells[j].firstChild, cal._cell$delegates);
                    }
                }


            }
        }


        function onCalendarHidden(sender, args) {


            if (sender.get_selectedDate()) {
                if (cal1.get_selectedDate() && cal2.get_selectedDate() && cal1.get_selectedDate() > cal2.get_selectedDate()) {
                    alert('The "From" Date should smaller than the "To" Date, please reselect!');
                    sender.show();
                    return;
                }
                //get the final date
                var finalDate = new Date(sender.get_selectedDate());
                var selectedMonth = finalDate.getMonth();
                finalDate.setDate(1);
                if (sender == cal2) {
                    // set the calender2's default date as the last day
                    finalDate.setMonth(selectedMonth + 1);
                    finalDate = new Date(finalDate - 1);
                }
                //set the date to the TextBox
                sender.get_element().value = finalDate.format(sender._format);
            }
        }


    </script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        From :
        <asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
        <cc1:CalendarExtender ID="CalendarExtender1" BehaviorID="calendar1" runat="server"
            Enabled="True" Format="yyyy/MM/dd" TargetControlID="TextBox1" OnClientShown="onCalendarShown"
            OnClientHidden="onCalendarHidden">
        </cc1:CalendarExtender>
        To :
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <cc1:CalendarExtender ID="CalendarExtender2" BehaviorID="calendar2" runat="server"
            Enabled="True" Format="yyyy/MM/dd" TargetControlID="TextBox2" OnClientShown="onCalendarShown"
            OnClientHidden="onCalendarHidden">
        </cc1:CalendarExtender>
    </div>
    </form>
</body>
</html>