コード例 #1
0
        public Dictionary <string, object> ResetCampaign(Campaign Record)
        {
            Dictionary <string, object> RetData = new Dictionary <string, object>();
            Boolean retvalue = false;
            int     iTot     = 0;

            try
            {
                google_uploader g = new google_uploader();
                g.bSingle       = false;
                g.user_is_admin = Record.user_is_admin;
                g.comp_code     = Record._globalvariables.comp_code;
                g.user_id       = Record._globalvariables.user_pkid;
                string str = g.Process(Record.cam_table_name, "name");
                if (str != "")
                {
                    g.ResetCampaign("doc_" + Record.cam_slno.ToString());
                }
                iTot = g.iTot;
            }
            catch (Exception Ex)
            {
                retvalue = false;
                throw Ex;
            }

            RetData.Add("total", iTot);
            RetData.Add("retvalue", retvalue);

            return(RetData);
        }
コード例 #2
0
        public Dictionary <string, object> Save(pim_docm Record, tablesd [] Records, string ServerImageUrl)
        {
            DataTable Dt_Tablesm = new DataTable();
            Dictionary <string, object> RetData = new Dictionary <string, object>();
            string  ErrorMessage = "";
            Boolean retvalue     = false;

            DBRecord Rec = null;

            Boolean is_campaign_table = false;

            int iSlno = 0;


            try
            {
                Con_Oracle = new DBConnection();

                sql        = "select * from tablesm where rec_company_code = '" + Record._globalvariables.comp_code + "' and tab_table_name = '" + Record.doc_table_name + "'";
                Dt_Tablesm = Con_Oracle.ExecuteQuery(sql);

                if (Dt_Tablesm.Rows.Count > 0)
                {
                    is_campaign_table = (Dt_Tablesm.Rows[0]["tab_campaign_table"].ToString() == "Y") ? true : false;
                }

                if (Dt_Tablesm.Rows.Count <= 0)
                {
                    Lib.AddError(ref ErrorMessage, "Entity Not Found");
                }


                //if (Record.doc_name.Trim().Length <= 0)
                //  Lib.AddError(ref ErrorMessage, "name Cannot Be Empty");


                if (ErrorMessage != "")
                {
                    throw new Exception(ErrorMessage);
                }

                if ((ErrorMessage = AllValid(Record, Dt_Tablesm.Rows[0])) != "")
                {
                    throw new Exception(ErrorMessage);
                }


                if (Record.rec_mode == "ADD")
                {
                    sql = "select nvl(max(doc_slno), 1000) + 1  as slno from pim_docm ";
                    if (Con_Oracle.DB == "SQL")
                    {
                        sql = "select isnull(max(doc_slno), 1000) + 1  as slno from pim_docm ";
                    }
                    sql += " where rec_company_code = '" + Record._globalvariables.comp_code + "' and doc_table_name ='" + Record.doc_table_name + "'";
                    //sql += " and doc_table_name = '" + Record.doc_table_name + "'";

                    iSlno = Lib.Conv2Integer(Con_Oracle.ExecuteScalar(sql).ToString());

                    Record.doc_slno = iSlno;

                    if (iSlno <= 0)
                    {
                        throw new Exception("Invalid SL#");
                    }
                }
                else
                {
                    iSlno = Record.doc_slno;
                }

                sql = "";
                string sql1 = "";


                Rec = new DBRecord();
                Rec.CreateRow("pim_docm", Record.rec_mode, "doc_pkid", Record.doc_pkid);
                Rec.InsertString("doc_name", Record.doc_name, "P");
                Rec.InsertString("doc_file_name", Record.doc_file_name, "P");
                Rec.InsertString("doc_store_id", Record.doc_store_id);
                Rec.InsertString("doc_grp_id", Record.doc_grp_id);

                if (Record.doc_file_name.Trim().Trim().Length <= 0)
                {
                    Rec.InsertString("doc_thumbnail", "");
                }
                if (Record.rec_mode == "ADD")
                {
                    Rec.InsertString("doc_slno", Record.doc_slno.ToString());
                    Rec.InsertString("doc_table_name", Record.doc_table_name);
                    Rec.InsertString("rec_company_code", Record._globalvariables.comp_code);
                    Rec.InsertString("rec_created_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_created_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_created_date", "GETDATE()");
                    }
                }
                if (Record.rec_mode == "EDIT")
                {
                    Rec.InsertString("rec_edited_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_edited_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_edited_date", "GETDATE()");
                    }
                }
                sql = Rec.UpdateRow();


                Rec = new DBRecord();
                Rec.CreateRow(Record.doc_table_name, Record.rec_mode, "doc_parent_id", Record.doc_pkid);
                foreach (tablesd mRow in Records)
                {
                    if (mRow.tabd_col_type == "DATE")
                    {
                        Rec.InsertDate("COL_" + mRow.tabd_col_name, mRow.tabd_col_value);
                    }
                    else if (mRow.tabd_col_type == "LIST")
                    {
                        Rec.InsertString("COL_" + mRow.tabd_col_name, mRow.tabd_col_id, "P");
                    }
                    else
                    {
                        Rec.InsertString("COL_" + mRow.tabd_col_name, mRow.tabd_col_value, "P");
                    }
                }

                if (Record.rec_mode == "ADD")
                {
                    Rec.InsertString("rec_company_code", Record._globalvariables.comp_code);
                    Rec.InsertString("rec_created_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_created_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_created_date", "GETDATE()");
                    }
                }
                if (Record.rec_mode == "EDIT")
                {
                    Rec.InsertString("rec_edited_by", Record._globalvariables.user_code);
                    if (Con_Oracle.DB == "ORACLE")
                    {
                        Rec.InsertFunction("rec_edited_date", "SYSDATE");
                    }
                    else
                    {
                        Rec.InsertFunction("rec_edited_date", "GETDATE()");
                    }
                }

                sql1 = Rec.UpdateRow();

                Con_Oracle.BeginTransaction();
                Con_Oracle.ExecuteNonQuery(sql);
                Con_Oracle.ExecuteNonQuery(sql1);
                Con_Oracle.CommitTransaction();
                Con_Oracle.CloseConnection();

                try
                {
                    if (is_campaign_table == false)
                    {
                        google_uploader g = new google_uploader();
                        g.bSingle   = true;
                        g.comp_code = Record._globalvariables.comp_code;
                        g.user_id   = Record._globalvariables.user_pkid;
                        string str = g.Process(Record.doc_table_name, "name");
                        if (str != "")
                        {
                            g.UploadData(Record.doc_pkid);
                        }
                    }
                }
                catch (Exception)
                {
                }

                retvalue = true;
            }
            catch (Exception Ex)
            {
                if (Con_Oracle != null)
                {
                    Con_Oracle.RollbackTransaction();
                    Con_Oracle.CloseConnection();
                }
                retvalue = false;
                throw Ex;
            }
            Con_Oracle.CloseConnection();
            RetData.Add("retvalue", retvalue);
            RetData.Add("slno", iSlno);

            string server = Lib.getPath(ServerImageUrl, Record._globalvariables.comp_code, Record.doc_table_name, Record.doc_slno.ToString(), false);

            RetData.Add("server", server);
            RetData.Add("thumbnail", Record.doc_thumbnail);

            return(RetData);
        }