Esempio n. 1
0
        public static bool PeriodBakingZeroTimer(int devicenumber)
        {
            try
            {
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_Zero_Autoclav", cn);

                cmd.Parameters.AddWithValue("intTimeStart", Convert.ToInt32(Varibale.Status_Baking[devicenumber]));

                cmd.Parameters.AddWithValue("intTimezero", PublicMehotd.time_php());

                cmd.Parameters.AddWithValue("timezero", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("dev_no", devicenumber);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-zero timer");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavZeroError);
                return(false);
            }
        }
Esempio n. 2
0
        private void NewLogInsertToDatabase()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Log_New", cn);

                cmd.Parameters.AddWithValue("dev_no", DeviceNumber);
                cmd.Parameters.AddWithValue("kind", Kind.ToString());
                cmd.Parameters.AddWithValue("comment", classEnumLog.ShowError(Type));
                cmd.Parameters.AddWithValue("level", Level.ToString());
                cmd.Parameters.AddWithValue("intTime", (Convert.ToInt32(PublicMehotd.time_php()) + Sec));
                cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime(Sec));
                cmd.Parameters.AddWithValue("datetimep", PublicMehotd.retStringShowDatetime());
                cmd.Parameters.AddWithValue("value", Val);
                cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();
            }
            catch (Exception ex)
            {
                //Enum.ClassEnumError.ShowErrorInMessageBox(EnumError.insertNewLogProbel);
                log_system.saveLogSystem(ex, "log_manager insert");
            }
        }
Esempio n. 3
0
        public bool PeriodAutoclavStart()
        {
            try
            {
                string timeStartAutoclav = PublicMehotd.time_php();

                //MessageBox.Show((Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString() + " X " + timeStartAutoclav);

                Varibale.Status_Autoclav[Dev_no] = (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                cmd.Parameters.AddWithValue("intTimestart", (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString());

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime(-1 * Varibale.Timer_Autoclav[Dev_no]));

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cmd.Parameters.AddWithValue("time_st", Varibale.Data_Timer_Max[Dev_no].ToString());

                cmd.Parameters.AddWithValue("temp_low_st", Varibale.Data_Temp_Min[Dev_no]);

                cmd.Parameters.AddWithValue("temp_high_st", Varibale.Data_Temp_Max[Dev_no]);

                cmd.Parameters.AddWithValue("pres_st", Varibale.Data_Pres_Min[Dev_no]);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();

                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-start-autoclav");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Esempio n. 4
0
        public static bool InsertToDatabase(int devicenumber, Enum.EnumTypeData type, Enum.EnumKindDevice kind, double value)
        {
            try
            {
                Boolean check = true;

                if (check)
                {
                    SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                    SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Data_new", cn);

                    cmd.Parameters.AddWithValue("dev_no", devicenumber);
                    cmd.Parameters.AddWithValue("type", type.ToString());
                    cmd.Parameters.AddWithValue("kind", kind.ToString());
                    cmd.Parameters.AddWithValue("value", value);
                    cmd.Parameters.AddWithValue("intTime", PublicMehotd.time_php());
                    cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                    cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime());
                    cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                    cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                    cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());
                    cmd.Parameters.AddWithValue("datetimep", Convert.ToDouble(PublicMehotd.retStringShowDatetime()));

                    cn.Open();
                    object obj = cmd.ExecuteScalar();
                    cn.Close();

                    if (Autoclav.sendServer_count == Varibale.save_count_autoclav_server)
                    {
                        Autoclav.sendServer_count = 0;
                    }
                    else
                    {
                        Autoclav.sendServer_count++;
                    }


                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "autoclav-insert database");
                //Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewDatalogforautoclav);
                return(false);
            }
        }
Esempio n. 5
0
        public bool PeriodBakingStart()
        {
            try
            {
                string timeStartBaking = PublicMehotd.time_php();

                Varibale.Status_Baking[Dev_no] = timeStartBaking.ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("intTimestart", timeStartBaking);

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-start");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Esempio n. 6
0
        public static void saveLogMsg(string msg)
        {
            string filepath = @"c:\log_monitoring\";
            string filename = PublicMehotd.RetStringPersianCalenderwithDash() + "-" + DateTime.Now.Hour.ToString("00") + ".txt";

            checkFileAndFolder(filename);

            using (System.IO.StreamWriter file =
                       File.AppendText(filepath + filename))
            {
                file.WriteLine("\n msg = " + msg);
                file.WriteLine("\n datep = " + PublicMehotd.RetStringPersianCalender());
                file.WriteLine("\n timep = " + PublicMehotd.RetStringLocalTime());
            }
        }
Esempio n. 7
0
        private static void newRecord(int num, Int64 number)
        {
            zarinReport.closeAllRcord(num);

            string type = "";

            if (num == 1 || num == 2)
            {
                type = "ghabl";
            }
            else
            {
                type = "bad";
            }

            string sql = "insert into zarin_report_counter" +
                         " (status , intTimeStart , intTimeEnd, timeStart, timeEnd , datep  , yearp , monthp , dayp , number , zarin_product , brand , vazn , baste_bandi , darb , counter_num )" +
                         " values " +
                         " ('counts' , '" +
                         PublicMehotd.time_php() + "' , '0' , '" +
                         PublicMehotd.RetStringLocalTime() + "' , '00:00:00' , '" +
                         PublicMehotd.RetStringPersianCalender() + "' , '" +
                         PublicMehotd.retStringYearPersian() + "' , '" +
                         PublicMehotd.retStringMonthPersian() + "' , '" +
                         PublicMehotd.retStringDayPersian() + "' , '" +
                         number.ToString() + "' , '" +
                         ClassEnumProduct.getProductZarinNumber(Convert.ToInt64(Varibale.zarin["zarin_product_" + type]))
                         + "' , '" +
                         Varibale.zarin["brand_" + type]
                         + "' , '" +
                         Varibale.zarin["vazn_" + type]
                         + "' ,  '" +
                         Varibale.zarin["baste_bandi_" + type]
                         + "' , '" +
                         Varibale.zarin["darb_" + type]
                         + "' , '" +
                         num.ToString()
                         + "')";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }
Esempio n. 8
0
        private static string[] calculateLastData(int id, Int64 number, string[] RecordData)
        {
            string NOWEND = PublicMehotd.time_php();

            //string[] RecordData = getRecordReportProduct(id);
            string intTimeEnd  = RecordData[9];
            string Counter_num = RecordData[10];
            string timeEnd     = RecordData[12];

            string[] x   = new string[10];
            string   sql = "";

            try
            {
                sql = "select top 1  * from Data where type = 'count' and device_no = '" + Counter_num
                      + "' and intTime < '" + NOWEND + "' and value in ( select  top 1 value from Data where type = 'count' and device_no = '" + Counter_num
                      + "'and intTime < '" + NOWEND + "'  order by id desc ) order by id asc";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    x[0] = dr["intTime"].ToString();
                    x[1] = dr["timep"].ToString();


                    cn.Close();
                    return(x);
                }
                else
                {
                    x[0] = PublicMehotd.time_php();
                    x[1] = PublicMehotd.RetStringLocalTime();
                    cn.Close();
                    return(x);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report end  record last data=" + sql);
                return(null);
            }
        }
Esempio n. 9
0
        public static bool PeriodAutoclavNaghes(int deviceNumber)
        {
            try
            {
                if (Varibale.Status_Autoclav[deviceNumber] != "")
                {
                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_End_autoclav", cn);

                    cmd.Parameters.AddWithValue("intTimeStart", Varibale.Status_Autoclav[deviceNumber]);

                    cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                    cmd.Parameters.AddWithValue("dev_no", deviceNumber);

                    cmd.Parameters.AddWithValue("intTimeend", PublicMehotd.time_php());

                    cmd.Parameters.AddWithValue("timeend", PublicMehotd.RetStringLocalTime());

                    cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.naghes.ToString());

                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();



                    Varibale.Status_Autoclav[deviceNumber] = "";

                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-autoclav naghes");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavEndNaghes);
                return(false);
            }
        }
Esempio n. 10
0
        private static void updateRecord(int id, Int64 number, string status)
        {
            string[] RecordData   = getRecordReportProduct(id);
            string   statusUpdate = RecordData[17];

            try {
                if (status == "end")
                {
                    endRecord(id, number, RecordData);
                }
                else
                {
                    string intTimeEnd      = "0";
                    string timeEnd         = "00:00:00";
                    string timeUpdateQuery = ", timeUpdate = '" + PublicMehotd.RetStringLocalTime() + "' ";
                    string sql             = "update zarin_report_counter set status = '" + status
                                             + "' , number = '" + number
                                             + "' , intTimeEnd = '" + intTimeEnd
                                             + "' , timeEnd = '" + timeEnd
                                             + "' " + timeUpdateQuery
                                             + " where id = " + id + " ";

                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();

                    if (number > 1000 && statusUpdate == "0")
                    {
                        updateFirstData(id, RecordData);
                    }
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report update record ");
            }
        }
Esempio n. 11
0
        private static void closeAllRcord(int num)
        {
            string sql = "update zarin_report_counter set status = 'end' ,timeEnd='" + PublicMehotd.RetStringLocalTime()
                         + "' , intTimeEnd = '" + PublicMehotd.time_php() + "'  where counter_num = " + num + " and  status = 'counts' ";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();

            removeNumberZero(num);
        }